gridview选择的行值

问题描述:

gridview一列链接按钮,让我选择第三行,但我需要输出第三行

您可以获取selected的值按以下方式排行,

Gridview1.SelectedRow.Cells [index] .Text;

哪里Gridview1-> Gridview的ID
索引->单元格编号
You can get values of selected row in following way,

Gridview1.SelectedRow.Cells[index].Text;

Where Gridview1 -> Id of Gridview
index -> cell No.




请参阅下面的链接.寻找解决方案可能会有所帮助.

http: //www.dotnetfunda.com/articles/article442-how-to-to-get-the-values-of-selected-row-from-a-gridview-using-aspnet.aspx [ http://r4r.co.in/asp.net/01/tutorial/asp.net/how_to_get_the_values_of_selecte.shtml [ ^ ]

谢谢,
Viprat
Hi,

See the below link. It may be help you to find the solution.

http://www.dotnetfunda.com/articles/article442-how-to-get-the-values-of-selected-row-from-a-gridview-using-aspnet.aspx[^]
http://r4r.co.in/asp.net/01/tutorial/asp.net/how_to_get_the_values_of_selecte.shtml[^]

Thanks,
Viprat



您需要玩datagridview的ItemCommand事件.当您单击链接按钮时(如您在第一列中所述),控件会将您带到该事件,您将在CommandEventArg e中获得选定的行.
只需执行以下操作

Hi,
you need to play with ItemCommand event of datagridview. as you click on the link button (as you said is in your first column) control will take you to that event where you would get the selected row inside CommandEventArg e.
just do as follows

bool val =  ((checkbox)e.item.findcontrol("yourCheckBoxName")).checked;



这样,您将获得复选框的值.



this way you would get the value of your check box.