webform中datagrid动态添加多个模板列和checkbox列的问题!
SqlDataAdapter da = new SqlDataAdapter(strComm,myConnection);
DataSet ds = new DataSet();
da.Fill(ds,"UserRight");
//ds.Tables[0].Columns.Add(new DataColumn("BoolValue", typeof(bool)));
DataView dv = new DataView();
dv = ds.Tables[0].DefaultView;
dg.DataKeyField="User_ID";
dg.DataSource=dv;
dg.DataBind();
因为添加的多个模板列和checkbox列的个数不确定,所以只能在后台代码中来实现,
checkbox列对应的是一个表中的部门,一个checkbox对应一个部门。
<asp:BoundColumn DataField="Position_Name" HeaderText="职位"></asp:BoundColumn>
<asp:BoundColumn DataField="User_Name" HeaderText="用户名"></asp:BoundColumn>
<Asp:TemplateColumn ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
<Asp:LinkButton ID="lb1" Runat="server" Runat="server">
<font color="White">新建任务</font></Asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="c1" runat="server" />
</ItemTemplate>
</Asp:TemplateColumn>
。。。。。。在接着添加多个checkbox列!
请高人指点~~~