使用ROW COMMAND OF GRIDVIEW获取行内文本框的值 [英] get value of textbox inside a row using ROW COMMAND OF GRIDVIEW

查看:96
本文介绍了使用ROW COMMAND OF GRIDVIEW获取行内文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试获取gridview的行命令事件中gridview所选行的文本框的值



我有以下内容:



Hi I am trying to get the value of the textbox of the selected row of the gridview

on the row command event of the gridview I have the following:

TextBox txtAEditTimeDepart = (TextBox)Default._def.GRDTech.SelectedRow.FindControl("txtEditTimeDepart");





怎么样返回给我一个空值和一个它没有引用任何东西的错误。



how ever it is returning me a null value and an error that it is not referring to anything.

推荐答案

试试这样:

Try like this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       try
       {
           if (e.CommandName == "Edit")
           {
               ImageButton img = (ImageButton)e.CommandSource as ImageButton;
               GridViewRow row = img.NamingContainer as GridViewRow;

               TextBox2.Text = ((Label)row.FindControl("txtEditTimeDepart")).Text;
           }

       }
       catch (Exception ex)
       {
           lblstatus.Text = "Error" + ex.ToString();
       }
   }


这篇关于使用ROW COMMAND OF GRIDVIEW获取行内文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆