如
<itemTemplate>
<asp:CheckBox id="Chkbox" Checked='<%# (DataBinder.Eval(Container.DataItem,"sub","{0}")=="1")?true:false%>' OnCheckedChanged="subs" AutoPostBack="True" runat=server />
</itemtemplate>
</asp:Templatecolumn>写事件时
public void subs(Object sender, EventArgs E)
{
CheckBox CB=(CheckBox)datelist.Items[?].FindControl("Chkbox");
....
}
<itemTemplate>
<asp:CheckBox id="Chkbox" Checked='<%# (DataBinder.Eval(Container.DataItem,"sub","{0}")=="1")?true:false%>' OnCheckedChanged="subs" AutoPostBack="True" runat=server />
</itemtemplate>
</asp:Templatecolumn>写事件时
public void subs(Object sender, EventArgs E)
{
CheckBox CB=(CheckBox)datelist.Items[?].FindControl("Chkbox");
....
}
if(CB.Checked)
{
CheckBox CB=(CheckBox)dgItem.FindControl("Chkbox");
经典例子,对你绝对有帮助.
Response.Write(dgItem.Controls[1].?);
应该是:
DataGridItem dgItem=(DataGridItem)((CheckBox)sender).Parent.Parent;
CheckBox CB=(CheckBox)dgItem.FindControl("Chkbox");int i = 0 ; // 1、2、3、4、……
Response.Write(dgItem.Cells[i].Text);
应该是:
DataGridItem dgItem=(DataGridItem)((CheckBox)sender).Parent.Parent;
CheckBox CB=(CheckBox)dgItem.FindControl("Chkbox");int i = 0 ; // 1、2、3、4、……
Response.Write(dgItem.Cells[i].Text);
{
CheckBox CB=(CheckBox)datelist.Items[i].FindControl("Chkbox");
if(CB.Checked)
{
Resopnse.wirte(i); //这个时候当选中CheckBox时就可以取出他的位置了。
}
}
// {
// if(((CheckBox)DataGrid1.Items[i].FindControl("CheckBoxName")).Checked)
// ....
// }