标题:求高手回答。无法将类型的对象强制转换为类型
只看楼主
uyjzhang0
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-4-20
结帖率:0
已结贴  问题点数:20 回复次数:1 
求高手回答。无法将类型的对象强制转换为类型
无法将类型为“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();
    }
搜索更多相关主题的帖子: void 
2013-04-20 17:16
Aviva_Wang
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:苏州
等 级:贵宾
威 望:26
帖 子:701
专家分:2382
注 册:2013-3-12
得分:20 
string nd = gvMark.Rows[i].Cells[1].Text.ToString();

asp
2013-04-20 20:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-404988-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067684 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved