我刚学,大家来帮帮我! Asp.net 2.0 中 页面载入时自动选择一个下拉列表框的值?我把值传过去(下拉列表框绑定后有这个值),我希望页面载入时下拉列表框中能自动选择相应的项. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // 假设这个值是传过来的string strDefault = "aaaa";if (this.DropDownList1.Items.FindByValue(strDefault) != null){ this.DropDownList1.ClearSelection(); this.DropDownList1.Items.FindByValue(strDefault).Selected = true;} Dim Item1 As ListItemFor i As Short = 1 To 12 Item1 = New ListItem(i, i) if item1.value="你传的值" then DropList.SelectedIndex = i exit for End ifNext To: minajo21(大眼睛)用你这方法后,我这里出现这种异常: 未将对象引用设置到对象的实例不知怎么办,望指点! DropDownList1.Items.FindByValue(strDefault).Selected = true To: minajo21(大眼睛)我是先绑定后,再用你说的这个方法去做的, 结果会出现"未将对象引用设置到对象的实例"的异常.你这个方法应该是没问题的,你能不能给一个例子让我参考? 关于ajax控件,updatepanel 删除图片的问题!麻烦各位了!! 初学.NET,希望大家可以给与指点。 vs2005初接触的一些疑惑 我的vs2005不知道怎么的不能新建网站了了 百分求助:DropDownList联动下拉框获取不到SelectedValue???? 谁能给一个好的数据库操作catch{}抛出错误的代码例子,采用马上结贴! 在触发器怎么得到昨天的日期 请各位高手赐教,在线用户的问题 求一个派出所户籍管理系统 关于checkbox选中的问题! 配置多个webconfig
// 假设这个值是传过来的
string strDefault = "aaaa";
if (this.DropDownList1.Items.FindByValue(strDefault) != null)
{
this.DropDownList1.ClearSelection();
this.DropDownList1.Items.FindByValue(strDefault).Selected = true;
}
For i As Short = 1 To 12
Item1 = New ListItem(i, i)
if item1.value="你传的值" then
DropList.SelectedIndex = i
exit for
End if
Next
不知怎么办,望指点!