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
查看全文
相关阅读:
利用userData实现客户端保存表单数据
随机提取10条记录
分页的文本显示
用VB.NET写的一个简易的RSS阅读器
怎样提高你的Google Adsense收入?
全球500家最大公司及网址
HTC教程
老百姓是这样买房的
使用JavaScript+XML实现分页
恋爱的奇妙感觉,当爱在靠近...
原文地址:https://www.cnblogs.com/pyt5208/p/979442.html
最新文章
《C++ Primer》 Part V (Advanced Topics)
boost库 智能指针
Visual Studio 使用 mysql++
boost::timer
HTTP协议
Ubuntu 学习
迭代器(转)
《TCP/IP详解1》笔记(第1章 概述)
《软件架构师应该知道的97件事》
《C++ Primer》 Part II(Containers and Algorithms)
热门文章
《TCP/IP详解1》笔记(第2章 链路层)
关于typedef的用法总结(转)
《C++ Primer》 Part I(The Basics)
《C++ Primer》 Part III(Classes and Data Abstraction)
ASP中利用OWC控件实现图表功能详解
JavaScript事件综合查询
用C#实现生成PDF文档
“汉语”迟早要淘汰“英语”(精品转贴)
利用XSL和ASP在线编辑XML文档
在关系数据库中保存大量XML文档
Copyright © 2011-2022 走看看