对不起, 按照这个
放置一个复选框中的GridView
这是一个例子 HTML代码中的GridView声明一个复选框现在
<asp:TemplateField HeaderText="chkbox">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"
oncheckedchanged="CheckBox1_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
有关事件复选框
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
GridViewRow row = ((GridViewRow)((CheckBox)sender).NamingContainer);
int index = row.RowIndex;
CheckBox cb1 = (CheckBox)Gridview.Rows[index].FindControl("CheckBox1");
string checkboxstatus;
if (cb1.Checked == true)
checkboxstatus = "YES";
else if(cb1.Checked == false)
checkboxstatus = "NO";
//Here Write the code to connect to your database and update the status by
//sending the checkboxstatus as variable and update in the database.
}
高级..这是一个很好的解决方案..非常感谢你为你的宝贵时刻.. – 2012-03-03 05:50:59
Hai高级...我遇到了你提出的另一个问题.. ij st试图设置autopostback = true复选框.. bt我ddin't工作。 事件不会触发,点击时复选框会被清除..怎么办..请帮助我..其非常紧急.. – 2012-03-06 12:32:53
您需要在OnPreRender中完成。 保护覆盖无效OnPreRender(EventArgs e){//您的代码} – sinanakyazici 2012-03-06 13:23:04