求高手回答。无法将类型的对象强制转换为类型
无法将类型为“System.Web.UI.LiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”代码如下: protected void gvMark_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int i = e.RowIndex;
string markId = gvMark.DataKeys[i].Value.ToString();
string nd = ((TextBox)(gvMark.Rows[i].Cells[1].Controls[0])).Text.ToString();
string mc = ((TextBox)(gvMark.Rows[i].Cells[2].Controls[0])).Text.ToString();
string bd = ((TextBox)(gvMark.Rows[i].Cells[3].Controls[0])).Text.ToString();
string qy = ((TextBox)(gvMark.Rows[i].Cells[4].Controls[0])).Text.ToString();
string gn = ((TextBox)(gvMark.Rows[i].Cells[5].Controls[0])).Text.ToString();
string yz = ((TextBox)(gvMark.Rows[i].Cells[6].Controls[0])).Text.ToString();
string gj = ((TextBox)(gvMark.Rows[i].Cells[7].Controls[0])).Text.ToString();
try
{
WebErp.DataBase dbms = new WebErp.DataBase();
string upstr = "update sale set nd='" + nd + "', mc='" + mc + "', bd='" + bd + "', qy='" + qy + "', gn='" + gn + "', yz='" + yz + "', gj='" + gj + "' where bh=" + int.Parse(markId);
dataBindDataGrid();//重新绑定gvMark的数据
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language='Javascript'>alert('更新成功!');</script>");
}
catch
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language='Javascript'>alert('更新失败!');</script>");
return;
}
this.gvMark.EditIndex = -1;
dataBindDataGrid();
}