asp.net 如何获取 dropdowlist(ajax取回的) 中的数据
dropdownlist通过ajax获取数据,然后填充
我现在要通过dropdownlist.SelectedItem.Text 来访问下拉框的数据,
(这时查找原代码,dropdownlist为空
HTML code:
<select name="drpRegulationsType" id="drpRegulationsType">
</select>
原因是操作Dom在内存中)
所以当dropdownlist.SelectedItem.Text提示"
未将对象引用设置到对象的实例"
如何访问?
没看明白
你是要在后台获取吗?
ajax动态填充的,后台不能直接获取到,
可以通过js在前台获取
对,在后台获取
要加一些代码:
HTML code:
<asp:TextBox id="tbx" runat="server" />
<select name="drpRegulationsType" id="drpRegulationsType" onchange="document.getElementById('tbx').value = this.value">
</select>
后台用tbx.Text代替dropdownlist.SelectedItem.Text
代码是手写,有错请修改
刚才少了个样式 <asp:TextBox id="tbx" runat="server" style="display:none"/>
相关问答:
select top 12 * from Product where [id] not in (select top 12 [id] from Product)
这样可以分页,但是我在后面想加个条件
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......
<table style="width: 1000px"><tr>
<td style="height: 38px; width: 35px;">
姓名</td>
......
我创建了一个物品浏览页面:bookview.aspx,其中在页面的左侧列出物品的分类:分类1,连接到页面bookview.aspx?id=1,其他依次类推,当页面第一次加载的时候设置id的默认值为1,运行程序发现页面一直出于重新加 ......
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......
C# code:
SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......