加一列控制列,在该列中加按钮,
<asp:TemplateColumn HeaderText="操作">
<HeaderStyle HorizontalAlign="Center" Width="100px"></HeaderStyle>
<ItemTemplate>
<asp:linkbutton Text="修改" CommandName="delete" ForeColor="blue" runat="server" ID="Linkbutton2" />
<asp:linkbutton Text="删除" CommandName="delete" ForeColor="blue" runat="server" ID="Linkbutton3" />
</ItemTemplate>
</asp:TemplateColumn>
DataGrid的AutoGenerateColumns="False",
在CS中用e.item.cell[第几列]来取出相对的值
<asp:TemplateColumn HeaderText="操作">
<HeaderStyle HorizontalAlign="Center" Width="100px"></HeaderStyle>
<ItemTemplate>
<asp:linkbutton Text="修改" CommandName="delete" ForeColor="blue" runat="server" ID="Linkbutton2" />
<asp:linkbutton Text="删除" CommandName="delete" ForeColor="blue" runat="server" ID="Linkbutton3" />
</ItemTemplate>
</asp:TemplateColumn>
DataGrid的AutoGenerateColumns="False",
在CS中用e.item.cell[第几列]来取出相对的值
加一列到表中:
DataColumn col = new DataColumn();
col.DataType = typeof(System.String);
col.ColumnName = "Selected";
col.DefaultValue = "N";
this.DataSource.Columns.Add(col);就行了。
然后在TableStyle里加上对应的一列。
this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridBoolColumn1});
取
dataGridBoolColumn1的值进行判断
然后
this.dataGridBoolColumn1 = new System.Windows.Forms.DataGridBoolColumn();
this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { this.dataGridBoolColumn1});
with this.dataGridBoolColumn1
.MappingName=列名
.HeaderText=标题名
.AllowNull = False '将此dataGridBoolColumn1设为两态
end with取
DataColumn dtcCheck = new DataColumn("是否发送");
dtcCheck.DataType = System.Type.GetType("System.Boolean");
dtcCheck.DefaultValue = true;
dtcCheck.AllowDBNull=false;
dtuser.Columns.Add(dtcCheck);这样绑定后,DataGrid就有了