DropDownList动态绑定问题? 如何设置DropDownList的默认选项为数据库内容的?例如:DropDownList有三项,分别为:初级,中级,高级(注:这三项的直接定义的,不是数据库中的); 现在有一条记录为中级,在前台修改的时候如何把“中级”赋给DropDownList的默认值? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(DropDownList.FindByText("中级")!=null){ DropDownList.SelectedValue="中级选项的value";} 错了,应该是这样if(DropDownList.Items.FindByText("中级")!=null) { DropDownList.SelectedValue="中级选项的value"; } <asp:ListItem Value="初级" >初级</asp:ListItem><asp:ListItem Value="中级" Selected="True>中级</asp:ListItem><asp:ListItem Value="高级" >高级</asp:ListItem> 谢谢wggygah5,那个RadioButtonList是不是跟这个原理一样啊? <asp:ListItem Value="初级" > 初级 </asp:ListItem> <asp:ListItem Value="中级" > 中级 </asp:ListItem> <asp:ListItem Value="高级" > 高级 </asp:ListItem> DropDownList1.Items.FindByText("中级").Selected = true; public void DataBind_dp(string id) { foreach (ListItem item in this.DropDownList1.Items) { if(item.Value.ToString().Equals(id)) { item.Selected=true; break; } } }DataBind_dp("中级");这样行么?我弄了半天没弄出来!! public void DataBind_dp(string id) { if(DropDownList.Items.FindByText(id)!=null) { DropDownList.SelectedValue=id; }} DataBind_dp("中级"); 这样是可以的,不过前提是你的DropDownList的“中级”选项的Text和Value都是“中级” 有用过componentArt Upload组件的吗?请进!(50分) 一个很简单的问题,大家都进来看看啊 关于textbox Microsoft JScript 运行时错误: 缺少对象 如何像WebQQ那样防止页面刷新 如何将xml文件添加进SQL数据库 有高手帮忙看下自定义页面不起作用的问题吗 无奈,求助 问题 急急急!!!! 关于post的 未找到路径"C:\inetpub\wwwroot\web\newslist.shtml"的一部分。 web页面如何传值
{
DropDownList.SelectedValue="中级选项的value";
}
if(DropDownList.Items.FindByText("中级")!=null)
{
DropDownList.SelectedValue="中级选项的value";
}
<asp:ListItem Value="中级" Selected="True>中级</asp:ListItem>
<asp:ListItem Value="高级" >高级</asp:ListItem>
<asp:ListItem Value="中级" > 中级 </asp:ListItem>
<asp:ListItem Value="高级" > 高级 </asp:ListItem>
DropDownList1.Items.FindByText("中级").Selected = true;
{
foreach (ListItem item in this.DropDownList1.Items)
{
if(item.Value.ToString().Equals(id))
{
item.Selected=true;
break;
}
}
}DataBind_dp("中级");这样行么?我弄了半天没弄出来!!
{
if(DropDownList.Items.FindByText(id)!=null)
{
DropDownList.SelectedValue=id;
}
} DataBind_dp("中级");
这样是可以的,不过前提是你的DropDownList的“中级”选项的Text和Value都是“中级”