使用gridview按钮将gridview的选定值传递到另一个页面到文本框。 [英] Passing of selected value of gridview to another page to textbox using button of gridview .

查看:166
本文介绍了使用gridview按钮将gridview的选定值传递到另一个页面到文本框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是anil在这里,我想将所选按钮行的griedview的值传递到另一个页面的另一个文本框,请帮助我,我搜索了很多但我得到的结果使用超链接按钮而不是按钮。

hi this is anil here , i want to pass value of griedview of selected row of button to another text box of another page , please help me , i search a lot but i am getting result using hyperlink button not with the button .

推荐答案

此因子中的Anil LinkBut​​ton和Button只有一个区别,一个是LinkBut​​ton,另一个是Button。那么你在LinkBut​​ton中编写的代码在Button中编写相同的代码,只需更改是否有任何LinkBut​​ton类型转换为Button。



现在主要问题是,发送所选行的文本框值的值。如果你能得到它,那么你也可以将它发送到另一个文本框。因此,使用GridView的RowCommand事件,并在其中捕获按钮单击Button或LinkBut​​ton的CommandName / CommandValue。然后在FindControl函数的帮助下获取TextBox或Label或任何其他控件的值。看看下面的代码。

Anil LinkButton and Button in this factor has only one difference which is the type, one is LinkButton and one is Button. So what ever code you are writing in LinkButton write the same code in Button, just change if there is any LinkButton typecasting to Button.

And now the main issue,to send value of the selected row's text box value. If you can get it then you can also send it to another textbox. So use RowCommand event of GridView and within that catch the button click with CommandName/CommandValue of Button or LinkButton. And then with the help of FindControl function get the value of either TextBox or Label or any other controls. Take a look on the code bellow.
string Ques = ((TextBox)GridViewFRM.Rows[i].FindControl("GVQuestionTextBox")).Text; 




protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
   {
        if (e.CommandName == "More")
        {
            string Ques = ((TextBox)GridViewFRM.Rows[i].FindControl("GVQuestionTextBox")).Text; 
        }
    }  


这篇关于使用gridview按钮将gridview的选定值传递到另一个页面到文本框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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