So aktualisieren Sie die SQLDATaSource einer Dropdownlist von Code-BehindC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 So aktualisieren Sie die SQLDATaSource einer Dropdownlist von Code-Behind

Post by Anonymous »

Ich habe zwei Dropdownlisten: < /p>

Code: Select all














< /code>

Code-Behind auf page_load < /code>: < /p>

strForDropDownList = @" FROM [Db].[dbo].[table1] WHERE [stat] = 'A'";
string pol = " AND ";
if (ddlTaskName.SelectedIndex == 0)
{
pol += " ([tcol] LIKE '%' OR [tcol] IS NULL) AND ";
}
else
{
pol += " [tcol] = '" + ddlTaskName.SelectedValue.TrimEnd() + "' AND ";
}
if (ddlService.SelectedIndex == 0)
{
pol += " (scol LIKE '%' OR scol IS NULL) AND ";
}
else
{
pol += " scol = '" + ddlService.SelectedValue.TrimEnd() + "' AND ";
}
strWhere = pol;
dsPopulateTaskName.SelectCommand = @"SELECT DISTINCT [tcol] 'Task Name'" + strForDropDownList + strWhere;
dsPopulateService.SelectCommand = @"SELECT DISTINCT scol 'Service'" + strForDropDownList + strWhere;
< /code>

Wenn die Seite geladen wird, beginnt alles mit %< /code> und populiert die Dropdownlisten korrekt. Wenn ich eine Option aus der Dropdown -Liste ddlService 
auswähle, zeigt der dspopulatetaskName.selectCommand die richtige Abfrage zum Wiederbelebung des DDLTaskName Dropdownlist an, aber es wird nicht aktualisiert.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post