<asp:DataGrid ID="DataGrid1" runat="server">
<SelectedItemStyle BackColor="White" Font-Bold="True" ForeColor="White" />
<AlternatingItemStyle BackColor="#CCFF99" />
<ItemStyle BackColor="White" />
<HeaderStyle BackColor="#99FF99" Font-Bold="True" ForeColor="Black" />
<FooterStyle BackColor="Black" />
<Columns>
<asp:TemplateColumn >
<ItemTemplate>
<asp:CheckBox runat=server ID=che />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Cou_num" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="Cou_ID" HeaderText="课程ID">
<ItemStyle Width="100px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Cou_name" HeaderText="课程名">
<ItemStyle Width="100px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Cou_flag" HeaderText="必/选修">
<ItemStyle Width="100px" />
</asp:BoundColumn>
</Columns>
<PagerStyle BackColor="#99FF99" Mode="NumericPages" />
</asp:DataGrid>
protected void Button1_Click(object sender, EventArgs e)
{
foreach (DataGridItem Item in DataGrid1.Items)
{
if (Item.ItemType == ListItemType.Item || Item.ItemType == ListItemType.AlternatingItem)
{
CheckBox cheb = ((CheckBox)Item.FindControl("che"));
if (cheb.Checked == true)
{
string str_status = "update lab_course set Cou_status=1 where Cou_num='" + Counum + "'";
Comm1 com_status = new Comm1();
com_status.ENQ(str_status);
Response.Write("<script>window.alert('学期课程添加成功!')</script>");
}
else
{
string str_status = "update lab_course set Cou_status=0 where Cou_num='" + Counum + "'";
Comm1 com_status = new Comm1();
com_status.ENQ(str_status);
}
}
}
}
我想获取<asp:BoundColumn DataField="Cou_num" Visible="False"></asp:BoundColumn>中Cou_num的值,怎么实现啊?
[此贴子已经被作者于2007-4-9 12:01:59编辑过]