从GridView中获取数据时在GridView的行选定 [英] Fetching Data from GridView When a Row in a GridView Selected

查看:134
本文介绍了从GridView中获取数据时在GridView的行选定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GridView.根据从该Gridview中选择的行,我必须从GridView中获取选定的数据并在TextBox中显示该数据.

我该怎么办?

I have a GridView. On the basis of rows selected from that Gridview I have to fetch the selected data from the GridView and display that data in a TextBox.

How can I do that?

推荐答案

希望这对您有用


Hope this works for you


TextBox2.Text = GridView1.SelectedRow.RowIndex.ToString();





or

textbox.text = GridView1.SelectedRow.Cells[2].Text;


数组ID可能会有所不同,具体取决于您要检索的单元格.


The array id may change depending on the cell u want to retrieve.


您可以添加一个按钮来选择网格视图行.

然后将命令名称"和命令参数"属性添加到此按钮中,作为
Commandname =选择" Commandargument =''<%#(GridviewRow.(Container.RowIndex))%>''

然后添加事件行命令
然后检查(e.commandname =="select")
你可以通过
获取行索引 int index = convert.toInt32(e.commandargument.tostring());


您可以从gridview的选定行中选择任何值,如下所示:
label lbl =(label)gridview1.rows [index] .findcontrol("ControlName");
textbox1.text = lbl.text;
You can add one button for selecting the grid view row.

Then add Command name and command argument property in to this button as
Commandname="Select" Commandargument=''<%#(GridviewRow.(Container. RowIndex))%>''

Then add the event row command
Then check if (e.commandname=="select")
u can get the row index by
int index=convert.toInt32(e.commandargument.tostring());


u can select any value from selected row in a gridview as
label lbl=(label)gridview1.rows[index].findcontrol("ControlName");
textbox1.text=lbl.text;


这篇关于从GridView中获取数据时在GridView的行选定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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