为什么我用
--------button事件-------
for(int i=0;i<this.dgrd_dz.Items.Count;i++)
{
CheckBox chktmp = (CheckBox)dgrd_dz.Items[i].Cells[0].FindControl("chkDel") ;
// string ss = chkDel.ClientID.ToString() ;
bool tmp = chktmp.Checked ;
if(chktmp.Checked)
{
int opt_no = Convert.ToInt16(this.dgrd_dz.Items[i].Cells[7].Text) ;
delRub.del_dz(opt_no) ;
}
}
------------DataGrid----
<Columns>
<asp:TemplateColumn HeaderText="请选择">
<HeaderStyle Width="50px" CssClass="trHeader"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox ID="chkDel" Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>有些checkbox我已经选中了,但是我找出来的checkbox的checked属性全是false????
--------button事件-------
for(int i=0;i<this.dgrd_dz.Items.Count;i++)
{
CheckBox chktmp = (CheckBox)dgrd_dz.Items[i].Cells[0].FindControl("chkDel") ;
// string ss = chkDel.ClientID.ToString() ;
bool tmp = chktmp.Checked ;
if(chktmp.Checked)
{
int opt_no = Convert.ToInt16(this.dgrd_dz.Items[i].Cells[7].Text) ;
delRub.del_dz(opt_no) ;
}
}
------------DataGrid----
<Columns>
<asp:TemplateColumn HeaderText="请选择">
<HeaderStyle Width="50px" CssClass="trHeader"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox ID="chkDel" Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>有些checkbox我已经选中了,但是我找出来的checkbox的checked属性全是false????
我现在把checkbox的text属性加上,调试的在这一句的时候
CheckBox chkDel= (CheckBox)dgrd_dz.Items[i].Cells[0].FindControl("chkDel") ;
它能够取正确的取到chkdel的text属性,但是就是checked属性怎么都是false,
是不是因为text属性是在绑定datagrid的时候加上的,而checked属性是后来在页面的时候才加的原因阿,
我试过在开始绑定的时候把checked属性设置为ture,他就能得到true的checked属性