zoukankan
html css js c++ java
GridView的RowCommand事件中取得行索引
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
...
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
//
如果是为数据行
...
{
ImageButton imgbtnup
=
(ImageButton)e.Row.Cells[
1
].FindControl(
"
btnMoveUp
"
);
//
找控件
imgbtnup.CommandArgument
=
e.Row.RowIndex.ToString();
//
设置与此BUTTON关联的命令参数
imgbtnup.Visible
=
e.Row.RowIndex
!=
0
;
ImageButton imgbtndown
=
(ImageButton)e.Row.Cells[
2
].FindControl(
"
btnMoveDown
"
);
imgbtndown.CommandArgument
=
e.Row.RowIndex.ToString();
imgbtndown.Visible
=
e.Row.RowIndex
!=
((DataSet)((GridView)sender).DataSource).Tables[
0
].Rows.Count
-
1
;
}
}
protected
void
GridView1_RowCommand(
object
sender, GridViewCommandEventArgs e)
...
{
if
(e.CommandName
==
"
MoveUp
"
)
...
{
int
index
=
Convert.ToInt32(e.CommandArgument);
//
取的行索引
DataKey key
=
this
.GridView1.DataKeys[index];
string
keyval
=
key.Value;
//
取得主键
}
else
if
(e.CommandName
==
"
MoveDown
"
)
...
{
int
index
=
Convert.ToInt32(e.CommandArgument);
DataKey key
=
this
.GridView1.DataKeys[index];
string
keyval
=
key.Value;
}
}
文章出处:
http://blog.csdn.net/sonce8/archive/2007/09/09/1777777.aspx
查看全文
相关阅读:
经济--股票--深圳指数基金
经济--年终奖理财攻略
经济--股票--基金经理打死不肯说的赚钱黑幕
经济--股票--基金定投
经济--股票--基金分类的三个角度
经济学--股票--必胜法则
经济--降息对股市是好消息还是坏消息?
PHP数组的排序函数
使用回调函数处理数组的函数
统计数组元素的个数和唯一性的函数
原文地址:https://www.cnblogs.com/pyt5208/p/979442.html
最新文章
Requests:Python HTTP Module学习笔记(一)(转)
Requests:Python HTTP Module学习笔记(二)(转)
python 遍历文件夹
python datetime date time详解
python datetime 时间日期处理小结
EasyUI 如何结合JS导出Excel文件
如何创建一个标准的Windows服务
Forward团队-爬虫豆瓣top250项目-需求分析
Forward团队-爬虫豆瓣top250项目-成员简介与分工
对软件工程课程的期望
热门文章
自我介绍
软件工程进阶
两个整型变量,交换两个数的值,竟然还有这种操作
期末建议
AJAX异步刷新
jquery实现多选框只能选择一个
jquery实现<body>中点击按钮后,在<tbody>中显示一连串文本框
经济--指数基金--腾安百发容易宝,BAT大战指数基金
经济--指数基金
经济--股票--上证指数
Copyright © 2011-2022 走看看