Я связываю Dropdownlist в моей веб -части, как это:
Код: Выделить всё
private void BindClientTypes()
{
DataTable dt = DB.GetAllClientTypes();
if (dt == null)
{
ltGlobalErrorMsg.Text = GlobalErrorMessage;
ltGlobalErrorMsg.Visible = true;
}
else
{
ddlClient.DataSource = dt;
ddlClient.DataValueField = "ID";
ddlClient.DataTextField = "Name";
ddlClient.DataBind();
ddlClient.Items.Insert(0, PleaseSelectItem);
}
}
That code works fine, and I can set the SelectedIndex after the data bind if I comment out this line:
Код: Выделить всё
ddlClient.Items.Insert(0, PleaseSelectItem);
Подробнее здесь: https://stackoverflow.com/questions/177 ... -control-c
Мобильная версия