我的GridView里面绑定了一个CommandField字段,我点击更新的时候 提示: Message="无法将类型为“System.Web.UI.WebControls.HyperLink”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。"
这是我绑定的更新事件代码:
protected void RowUpdating(object sender,GridViewUpdateEventArgs e)
{
string A = GridView1.DataKeys[e.RowIndex].Value.ToString();
string B = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
string C = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
DateTime D = DateTime.Now;
string E = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();
string F = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim();
string G = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim();
string s = "update news set title='"+B+"',source='"+C + "',publictime='"+D+"',newscontent='"+E +"',picture='"+ F +"',hits='"+G +"'where newsID='"+ A+"'";
M.esql(s);
Response.Write("<script language=javascript> alert('数据更新成功!');window.location='ManagerNews.aspx'</script>");
}
麻烦各位了,我好急的!
DIEA
梦里花落0921
素胚勾勒不出你
慕侠2389804
茅侃侃
蛊毒传说
jeck猫
泛舟湖上清波郎朗
婷婷同学_
哆啦的时光机
相关分类