<asp:GridView ID="FireFighters" runat="server" AutoGenerateColumns="false" OnRowDataBound="FireFighters_RowDataBound" >
<Columns>
<asp:BoundField HeaderText="שם הכבאי" DataField="username" />
<asp:CheckBoxField HeaderText="מצוות לאירוע" DataField="IsLinked" />
</Columns>
</asp:GridView>
我不能添加和id到ASP:CheckBoxField字段,我试着给它像这样从后台代码:
foreach(GridViewRow gvr in FireFighters.Rows)
{
lst.Add(new FireFighter{username=gvr.Attributes["id"].ToString(),IsLinked=((gvr.Cells[1] as Control) as CheckBox).Checked});
}
但它的空,我怎么能得到复选框的值(选中或不选)?
为什么你不能添加一个ID到复选框? – nZeus 2015-03-24 22:18:57
在这里你可以看到如何在GridView中查找控件:http://stackoverflow.com/questions/6873973/how-to-find-control-in-templatefield-of-gridview – nZeus 2015-03-24 22:21:06
@nZeus你不能添加一个id以asp:CheckBoxField,我希望我能 – 2015-03-24 22:22:20