
在选择事件中用GridView1SelectedRowFindControl(按钮ID)来查找按钮。
或者给选择按钮加CommandArgument和CommandName参数用来传递名和参数更方便一些。
你的问题没说清楚,是要取得当然选择的行号,还是当然编辑的行号
当然所选择的行号:int
index=gvSelectedIndex;
当然所编辑的行号:int
index
=
gvEditIndex;
前台Gridview中:
后台方法:
if
(eCommandName
==
"MyCommandList")
{
LinkButton
btn
=
(LinkButton)eCommandSource;
GridViewRow
row
=
(GridViewRow)btnParentParent;
string
MacID
=
eCommandArgumentToString();
string
sql
=
"SELECT
MacID,Day_StartUp,Day_ShutDown,ABS(Day_StartUp-Day_ShutDown)
AS
Day_StartShut,col_date";
sql
+=
"
From
DW10048
WHERE
(col_date>='"
+
txtStartDayValue
+
"'
and
col_date
<='"
+
txtEndDayValue
+
"')
and
macid
=
'"
+
MacID
+
"'";
sql
+="
order
by
col_date
desc";
DataTable
dtlist
=
l_HelpGetDataTable(sql);
DataView
view
=
dtlistDefaultView;
GvList1DataSource
=
view;
GvList1DataBind();
}
另外,虚机团上产品团购,超级便宜
在 GridView_RowCommand 事件中
int index = ConvertToInt32(eCommandArgument);
就是当前行号
===============================
你只是取行号在事件里这样写就可以了。
如果你要给CommandArgument赋值才需要在Button的属性里绑定。
dataGridView1SelectedRows[0]Cells[0]Value;
dataGridView1SelectedRows[0]Cells[1]Value;
dataGridView1SelectedRows[0]Cells[2]Value;
SelectedRows用户选中的行集合
Cells选中行的单元格集合
当前所选择行(选择多行的第一行)的第0、1、2单元格的值。
int index = gvrowRowIndex。
//获取当前行的某列值string userid=GridView1Rows[index]Cells[列索引]TextTrim()。它的主要作用是就是在ASPNET页面中显示一个超链接。当这个链接被按动的时候,页面就会往服务器端传递信息,并且在服务器端来处理相应的事件。ASPNET LinkButton组件的重要的组成内容:LinkButton组件的常用属性、事件代表的意思;Text这是-一个属性,就是LinkButton组件显示的文字
以上就是关于GridView中如何获取选择按钮的ID值全部的内容,包括:GridView中如何获取选择按钮的ID值、gridview中如何点击LinkButton按钮取得该行的行号、如何点击按钮获取gridview中的某一列的值!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)