| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 713 人关注过本帖
标题:gridview里的编辑功能o怎么实现--自己写了点可是。。。。
只看楼主 加入收藏
雪夜白狼
Rank: 1
等 级:新手上路
帖 子:65
专家分:0
注 册:2008-3-24
收藏
 问题点数:0 回复次数:0 
gridview里的编辑功能o怎么实现--自己写了点可是。。。。
代码如下:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;//设置编辑索引
        this.getbinder();

    }

 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        OleDbConnection conn;
        conn = DB.DBconntionadmin();
        conn.Open();

        string ID = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
        GridViewRow row = this.GridView1.Rows[e.RowIndex]; //定义更新行对象
        string sql3 = "update admin set username='" + ((TextBox)(row.Cells[1].Controls[0])).Text.ToString() + "' and userpwd='" + ((TextBox)(row.Cells[1].Controls[2])).Text.ToString() + "' and popedom='" + ((TextBox)(row.Cells[1].Controls[3])).Text.ToString() + "' where id=" + ID;
        OleDbCommand com = new OleDbCommand(sql3,conn);
        com.ExecuteNonQuery();
        GridView1.EditIndex = -1;
        conn.Close();
        getbinder();}


当点击编辑的时候
当前行并不显示编辑状态
如果点击更新显示错误:

无法将类型为“System.Web.UI.DataBoundLiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.InvalidCastException: 无法将类型为“System.Web.UI.DataBoundLiteralControl”的对象强制转换为类型“System.Web.UI.WebControls.TextBox”。


是怎么会是啊?
搜索更多相关主题的帖子: gridview 
2008-05-14 19:52
快速回复:gridview里的编辑功能o怎么实现--自己写了点可是。。。。
数据加载中...
 
   



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

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