Datagridview的RowHeader如何设成复选框(checkboxcolumn)?
如题!Datagridview的RowHeader如何设成复选框(checkboxcolumn)?
datagridview rowheader --------------------编程问答--------------------
<script type="text/javascript">--------------------编程问答-------------------- sorry, 我需要的是winform --------------------编程问答-------------------- 直接添加一列不行吗? --------------------编程问答-------------------- 因为要用到公用的方法去更新数据库,所有列跟数据库对应的,所以不想加列
function Check(parentChk,ChildId)
{
var oElements = document.getElementsByTagName("INPUT");
var bIsChecked = parentChk.checked;
for(i=0; i<oElements.length;i++)
{
if (IsCheckBox(oElements[i]) && IsMatch(oElements[i].id, ChildId))
{
oElements[i].checked = bIsChecked;
}
}
}
function IsMatch(id, ChildId)
{
var sPattern ='^grd_List.*'+ChildId+'$';
var oRegExp = new RegExp(sPattern);
if(oRegExp.exec(id))
return true;
else
return false;
}
function IsCheckBox(chk)
{
if(chk.type == 'checkbox')
return true;
else
return false;
}
</script>
<asp:GridView ID="grd_List" runat="server" AutoGenerateColumns="false" Font-Size ="12"
Width="100%" style="margin-left: 0px" OnRowDataBound ="grd_List_RowDataBound" >
<Columns>
<asp:BoundField DataField="table_name" HeaderText="表名" Visible ="false" />
<asp:BoundField DataField="cn_name" HeaderText="表单名称" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="cbQuery" runat="server" Text="运行"/>
</ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="chkrun" name="chkrun" onclick="Check(this,'cbQuery')" />运行
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbInsert" Text="新增"></asp:CheckBox>
</ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="chkadd" name="chkadd" onclick="Check(this,'cbInsert')" />新增
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbUpdate" Text="修改"></asp:CheckBox>
</ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="chkupdate" name="chkupdate" onclick="Check(this,'cbUpdate')" />修改
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox runat="server" ID="cbDelete" Text="删除"></asp:CheckBox>
</ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="chkdelete" name="chkdelete" onclick="Check(this,'cbDelete')" />删除
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate >
<asp:CheckBox runat="server" ID="cbDownload" Text="导出"></asp:CheckBox>
</ItemTemplate>
<HeaderTemplate>
<input type="checkbox" id="chkdownload" name="chkdownload" onclick="Check(this,'cbDownload')" />导出
</HeaderTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
没有数据可显示
</EmptyDataTemplate>
<HeaderStyle Font-Size="Smaller" />
</asp:GridView>
补充:.NET技术 , C#