在后台取datalist中HTML控件(想完成,数据库中有的就选中功能)
前台代码<asp:DataListID="DataList1"runat="server"onitemdatabound="DataList1_ItemDataBound...
前台代码
<asp:DataList ID="DataList1" runat="server"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td>
<input id="dongtai" name="dongtai" value='<%#Eval("n_id") %>' type="checkbox"/></td>
<td><%#Eval("n_newstitle")%></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
后台方法为
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
//((System.Web.UI.HtmlControls.HtmlInputCheckBox)e.Item.FindControl("dongtai")).Checked = true;
CheckBox cb= e.Item.FindControl("dongtai") as CheckBox;
}
这样取不到 求高手解决 展开
<asp:DataList ID="DataList1" runat="server"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td>
<input id="dongtai" name="dongtai" value='<%#Eval("n_id") %>' type="checkbox"/></td>
<td><%#Eval("n_newstitle")%></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
后台方法为
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
//((System.Web.UI.HtmlControls.HtmlInputCheckBox)e.Item.FindControl("dongtai")).Checked = true;
CheckBox cb= e.Item.FindControl("dongtai") as CheckBox;
}
这样取不到 求高手解决 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询