我在DateGrid中加了模版列
<asp:TemplateColumn HeaderText="成绩">
<ItemStyle Width="42px" />
<ItemTemplate>
<asp:TextBox ID="text" runat="server" Width="40px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
下面是Button1的事件 怎么数据加不进去啊?而且也不报错,还会跳出提示框"输入成功!"
大家帮我看看哪出错了?
protected void Button1_Click(object sender, EventArgs e)
{
foreach (DataGridItem Item in DataGrid1.Items)
{
if (Item.ItemType == ListItemType.Item || Item.ItemType == ListItemType.AlternatingItem)
{
TextBox tet = (TextBox)Item.FindControl("text");
if (tet.Text != null)
{
string str_mark = "update lab_students set mark='" + int.Parse(tet.Text) + "' where user_ID='" + Item.Cells[1].ToString() + "'";
co_m.ENQ(str_mark);
}
}
}
Response.Write("<script defer>alert('输入成功!');</script>");
}