A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 李礼彬 中级黑马   /  2013-5-13 17:59  /  1240 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  2.     {
  3.         string s = GridView1.Rows[e.NewEditIndex].Cells[2].Text;
  4.         Label1.Text = s;
  5.     }
复制代码
比如这个。label1的值为空,取出的值为空。但是显示的有数据呀,其他的事件也有的会这样


评分

参与人数 1技术分 +1 收起 理由
苏波 + 1

查看全部评分

1 个回复

倒序浏览
1. 加个控件集controls;
2. string s= GridView1.Rows[e.NewEditIndex].Cells[2].Controls[0].Text;//
     Label1.Text = s;//
3. Controls[0] 获取到的只是一个控件,这个控件不知道什么类型,所以必须显示转型;
4.  string s= ( GridView1.Rows[e.NewEditIndex].Cells[2].Controls[0].Text)as  Label).Text;
     或者试试这个 string s= (this.GridView1.Rows[e.NewEditIndex].FindControl("Label1") as Label).Text.Trim();

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马