All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#教程:Windows服务概述
调用xsl来解析xml文档(js异步_JavaScript技术_编程技术
IIS运行不了ASP.NET的解决办法_.net资料_编程技术
SQL语言快速入门之一_mssql学习_编程技术
菜鸟学习:动态网页PHP基础学习笔记_php资料_编程技术
visual c++中ActiveX控件创建实例
从,PHP,迁移到,ASP.NET(3)_[Asp.Net教程]
滑动展开/收缩广告代码实例效果_JavaScript技术_编程技术
如何无需编程便将数据SQL导出到MYSQL_[SQL,Server教程]
教你轻松给流程增加权限控制程序_.net资料_编程技术
Reading number is top 10 pictures
More attractive than sora aoi2
The wise woman of chest2
刘亦菲写真集2
这玉米,买还是不卖?
A man's favorite things3--ZhouWeiTong
Look for from human art net, is good--2
Chinese paper-cut grilles art appreciation1
The real super beauty14
Other people's teacher VS my teacher
初吻给了谁?
Download software ranking
Desire a peach blossom
Sora aoi, the nurse, uniform ,nursing assistant
终极变速大师Speeder3.26
网络管理员第三版
Boxer's Top ten classic battle7
Tram sex maniac 2 (H) rar bag3
Photoshop 8.0图象编辑软件
WebService在.NET中的实战应用教学视频 → 第4集
Unix video tutorial2
Tram sex maniac 2 (H) rar bag8
delv published in(发表于) 2014/1/8 7:02:56 Edit(编辑)
GridViewRow可以任意位置单击引发事件的方法_[Asp.Net教程]

GridViewRow可以任意位置单击引发事件的方法_[Asp.Net教程]

GridViewRow可以任意位置单击引发事件的方法_[Asp.Net教程]

GridView 是 ASP.NET 2.0 中应用最为广泛一个控件,几乎所有的数据操作都需要它,正如我们平常所应用的,可以编辑、删除、选择等等,但如果客户有需要通过单击行而引发超链接或者进入行编辑状态时,我们该如何实现,这里介绍了一种方法来实现此功能。它将允许你通过点击行的任何一个位置而引发你所需要的事件。

  首先为 GridView 填充数据


private void BindData()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand("SELECT * FROM Users", myConnection);
SqlDataAdapter ad = new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
ad.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}


接下来我们在 GridView_RowDataBound 事件中为 GridViewRow 赋予单击属性


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string alertBox = "alert('";
if (e.Row.RowType == DataControlRowType.DataRow)
{
alertBox += e.Row.RowIndex;
alertBox += "')";
e.Row.Attributes.Add("onclick", alertBox);
}
}


好了,很简单的方法,希望对你有用!


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.