Gridview选择按钮 [英] Gridview Select Button

查看:47
本文介绍了Gridview选择按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要您的帮助,请帮助我.

我正在使用ASP.NET 2008开发Web应用程序.在WebForm1上,我创建了GridView1,并且SELECT按钮位于所有行的GridView第一列上.
当用户单击其中之一时,如何设置和处理它?如何从单击选择"按钮的特定行中检索数据?

列内如何编码?

干杯,
Lennie

Hi Good Guys

I need your help, please help me.

I am using ASP.NET 2008 to develop Web application. On the WebForm1, I have created GridView1 and the SELECT button are on the GridView First column of all the rows.

How do I set it up and handle it when the user click on one of them, how do I retrieve the data from the specific row where the Select Button is clicked?

How the coding within column ?

Cheers,
Lennie

推荐答案

对于选择按钮,会将选择命令设置为选择".现在,在gridview的selectedindexchanged事件中,您可以将选定的GridView行的引用获取为Gridview1.SelectedRow,它返回类型为GridviewRow的行.
for a select button there will be select command set to Select. Now in selectedindexchanged event of gridview you can get the reference to selected GridView row as Gridview1.SelectedRow which returns a row of type GridviewRow.


希望这些链接将帮助您学习Gridview操作:
尝试以下链接:
目录:ASP.NET 2.0的GridView示例 [ Gridview示例 [
Hope these links would help you learning Gridview operations:
Try the following links:
Table of Contents: GridView Examples for ASP.NET 2.0[^]
Gridview Samples[^]


protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {
       int selectedRow = GridView1.SelectedIndex;
       //teaking the value of first column in selected row
       string firstColumn = GridView1.Rows[selectedRow].Cells[0].Text;
       //taking the value of second column in selected row
       string secondColumn = GridView1.Rows[selectedRow].Cells[1].Text;
   }


这篇关于Gridview选择按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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