Click here to Skip to main content
13,198,563 members (22,791 online)
Click here to Skip to main content
Add your own
alternative version

Stats

22.7K views
9 bookmarked
Posted 3 Jan 2012

How to click/select Row in ASP.NET GridView or HTML Table

, 27 Jun 2012
Rate this:
Please Sign up or sign in to vote.
The above code will slow down the browser and the browser can hang when Rows in Grid will be 10000 or above.Please view the below suggestion:CS Codeprotected void grvGroups_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { ...

The above code will slow down the browser and the browser can hang when Rows in Grid will be 10000 or above. Please view the below suggestion:

CS Code

protected void grvGroups_RowDataBound(object sender, GridViewRowEventArgs e)
{
 if (e.Row.RowType == DataControlRowType.DataRow)
  {
    e.Row.Attributes.Add("onclick", "setGridValue('" + e.Row.ClientID + "')");
  }
}

HTML Code

.sel
{
     color: #303030;
     font-size:3em;
     font-weight:bold;
     cursor:default;
}
.desel
{
     color: #909090;
     font-size:2em;
     font-weight:normal;
     cursor:pointer;
}

 

var oldro;
function setGridValue(ro)
{
 var rs=document.getElementById(ro);
 if(oldro!=null)
 {
  if(rs.className=="sel")
   return;
  oldro.className="desel";
 }
 rs.className="sel";
 oldro=rs;
}

And forget then loop.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Technoses
Software Developer (Senior) Super Eminent Softwares
India India
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

42 members


You may also be interested in...

Comments and Discussions

 
GeneralGreat! Pin
Pritesh Aryan10-Dec-12 23:50
memberPritesh Aryan10-Dec-12 23:50 
GeneralMy vote of 5 Pin
sanjeev kumar sharma Eng26-May-12 1:12
membersanjeev kumar sharma Eng26-May-12 1:12 
well done
GeneralRe: Thank for your reply! Actually, I have changed all rs with _... Pin
beginner201129-Jan-12 15:17
memberbeginner201129-Jan-12 15:17 
GeneralIt didn't work. I have insert if(rs==null) alert("null") af... Pin
beginner201118-Jan-12 20:21
memberbeginner201118-Jan-12 20:21 
GeneralRe: you r using var _row = document.getElementById(ro) and not ... Pin
Technoses22-Jan-12 20:49
groupTechnoses22-Jan-12 20:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 27 Jun 2012
Article Copyright 2012 by Technoses
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid