有没有办法将数据源绑定到带runat=server属性的html选择标记.
<select runat="server" onchange="showdistrict();" class="textbox" id="DpCity" name="DpCity">
<option value="0">unknow</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我自己找到了答案,所以我会分享.通过使用runat ="server"属性并分配一个id来控制它将在后面的代码中访问.例如DpCity是我的html选择标记,所以我可以使用下面的代码来绑定数据源:
DpCity.DataTextField = "title";
DpCity.DataValueField = "val";
DpCity.DataSource = SrCity;
DpCity.DataBind();
Run Code Online (Sandbox Code Playgroud)
就像asp下拉列表框一样
| 归档时间: |
|
| 查看次数: |
16084 次 |
| 最近记录: |