如何从code-背后显示之前选择在弹出ppopulated DropDownList的选项$ P $ [英] How to select a prepopulated dropdownlist option in a popup before showing from code-behind
本文介绍了如何从code-背后显示之前选择在弹出ppopulated DropDownList的选项$ P $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这行选定的索引设置为正确的号码:
This line sets the selected index to the correct number:
ddlCliNewMsg.SelectedIndex = ddlCliNewMsg.Items.IndexOf(ddlCliNewMsg.Items.FindByValue(dr["ClientText"].ToString()));
但是,当弹出的负载,0指数被选中。
But when the popup loads, the 0 index is selected.
推荐答案
修改
if (dr["ClientText"].ToString().Length > 0)
{
ddlCliNewMsg.SelectedValue = dr["ClientText"].ToString();
}
要
if (dr["ClientText"].ToString().Length > 0)
{
ddlCliNewMsg.ClearSelection(); //making sure the previous selection has been cleared
ddlCliNewMsg.Items.FindByValue(dr["ClientText"].ToString()).Selected = true;
}
这篇关于如何从code-背后显示之前选择在弹出ppopulated DropDownList的选项$ P $的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文