在RowUpdating的事件里,怎么样获取
<asp:BoundField></asp:BoundField>
里的值???
<asp:BoundField></asp:BoundField>
里的值???
解决方案 »
- 请教如何获取TreeView选中节点和其所有子节点的值
- Convert.toDemical 问题
- 购物车产品数量更改问题
- 我用GridView做分页,但有个问题它会显示一行这样的行,请问怎么去掉,谢谢
- 不刷新DataList的情况下,在ItemCommand在中取隐藏在Datalist控件的值?
- <table align="center">中的align属性过期了?
- 急需<<C#设计模式>>光盘上的随书代码
- ajax跨域问题 jsonp
- 急救:如何远程打开文件?
- 各位为什么我在Button按钮里用这个事件怎么没反应...OnClientClick
- 求助:关于ASP.NET读取excel文件
- 在文本框中的密码如何保持?
if (row != null)
{
TextBox tb = row.Cells[n].Controls[0] as TextBox; //change n to the position of your bound field
if (tb != null)
{
Response.Write(tb.Text);
}
}
{
try
{
GridViewRow myrow = GridView1.Rows[e.RowIndex];
string name = ((TextBox)myrow.Cells[1].Controls[0]).Text;
string pwd = ((TextBox)myrow.Cells[2].Controls[0]).Text; string sql = "update dc4_user_def set username='" + name + "',password='" + pwd + "'where userid='" + userid + "'";
DBHelper.ExcuteQuery(sql); GridView1.EditIndex = -1;
this.BindGridView();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
然后点击更新,可是就是更新不了更新按钮的代码
protected void GVeditor_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
try
{
string cj = ((TextBox)e.NewValues[5]).Text
string kccj = ((TextBox)e.NewValues[6]).Text).Text;
string xk = ((TextBox)e.NewValues[1]).Text;
string km = ((TextBox)e.NewValues[4]).Text; string cmdtext = "update 成绩 set 成绩='" + cj + "',考查成绩='" + kccj + "' where 成绩.学生='" + xk + "' and 成绩.科目 in (select ID from 科目 where 科目.科目='" + km + "')";
SqlConnection sqlconn = new SqlConnection(sqllink.sqlconn());
sqlconn.Open(); SqlCommand sqlcomm = new SqlCommand(cmdtext, sqlconn);
sqlcomm.ExecuteNonQuery();
sqlconn.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
this.GVeditor.DataSource = gvBind();
this.GVeditor.DataBind();
GVeditor.EditIndex = -1;
//////////////////HTML代码
<asp:GridView ID="GVeditor" runat="server" Width="100%" Height="72px" AutoGenerateColumns="False" OnRowCancelingEdit="GVeditor_RowCancelingEdit" OnRowEditing="GVeditor_RowEditing" OnRowUpdating="GVeditor_RowUpdating" OnRowUpdated="GVeditor_RowUpdated" >
<Columns>
<asp:BoundField DataField="学号" HeaderText="学号" ReadOnly="True" />
<asp:BoundField DataField="班级" HeaderText="班级" ReadOnly="True" />
<asp:BoundField DataField="姓名" HeaderText="姓名" ReadOnly="True" />
<asp:BoundField DataField="科目" HeaderText="科目" ReadOnly="True" />
<asp:TemplateField HeaderText="成绩">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("成绩") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("成绩") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="考查成绩">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" Text='<%#Eval("考查成绩")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#Eval("考查成绩") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True"></asp:CommandField>
</Columns>
</asp:GridView>