ASP.NET 中自带的 GridView 控件显示 boolean 类型字段时,如何设置该列为可以编辑的状态?
------解决方案--------------------------------------------------------
用模板列
<asp:TemplateField HeaderText="删除" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" OnClientClick=" javascript:return confirm('你确认要删除吗?')"
CommandName="Delete" Text="删除"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
然后:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox CheckBox1 = (CheckBox)row.Cells[4].FindControl("CheckBox1");
//在这里处理你想要的数据
}
}