Search
Thursday, September 09, 2010 ..:: Home ::.. Register  Login
 .NET Links Minimize

 Print   
 My Links Minimize

 Print   
 Recent Blog Entries Minimize
Dec 20

Written by: Wil Dobson
12/20/2007 2:51 PM

TO SELECT A ROW ONCLICK:

Firstly, you will need to enable row selections for your datagrid. this will place the proper javascript in your page for what is to come. This will place a select button on your page, but you can convert that column into a template and make the linkbutton visible=false.

you need a OnRowCreated event handler, so add this to your gridview's source (OnRowCreated="GridView1_RowCreated") or just set up a handler through the gridviews Events Property window.

The event handler will look something like this:

int RowCount = 0;
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
// get the row index, add onclick attribute for javascript:__doPostBack('GridView1','Select$0')
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "javascript:__doPostBack('" + ((GridView)sender).ID + "','Select$" + (RowCount - 1).ToString() + "')");
e.Row.Attributes.Add("onmouseover", "JavaScript:this.style.cursor='hand';");

}
RowCount++;
}

Copyright ©2007 Wil Dobson

Tags:

  
 PS: Minimize

 Print   
 Sponsors Minimize

Get your own Komets drinking Stein!

Get your KOMETS gear!
Proceeds go for player awards @ the end of each season.

  Quality Geek Gear from GeeksWithGuns.com

We use DiscountASP!! Click to join up!


 Print   
 Facebook Minimize

Wil Dobson's Facebook profile


 Print   
 Blogs Minimize

 Print   
 Manage Blog Minimize
You must be logged in and have permission to create or edit a blog.

 Print   
 Blog Archives Minimize

 Print   
Copyright 2008 by Wil Dobson   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2010 by DotNetNuke Corporation