Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need my gridview to be clickable so i'm using GridView1_RowDataBound. But when system load large data to gridview, it hang due to it run GridView1_RowDataBound once everytime it load 1 row of data to gridview.
How to make my gridview cllickable but not causing the hang?


My code looked like below:

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {

          if (e.Row.RowType == DataControlRowType.DataRow)
     {

                 e.Row.Attributes["onClick"] = "location.href='ViewImage.aspx?id=" + DataBinder.Eval(e.Row.DataItem, "Machine Name") + "'";
     }

 }
Posted

Hi,

Try this

e.Row.Attributes.Add("onclick", "javascript:window.location.href="/KB/answers/page.aspx"?ID=" + e.Row.Cells[0].Text + "';");
 
Share this answer
 
Use griview paging while binding large amount of data as well as try ashokmmrk solution

--Sj
 
Share this answer
 
Thank you!
Do u guys mind to explain why following code is better?

e.Row.Attributes.Add("onclick", "javascript:window.location.href="/KB/answers/page.aspx"?ID=" + e.Row.Cells[0].Text + "';");
 
Share this answer
 
Comments
Vani Kulkarni 10-Dec-12 23:52pm    
This is not an answer, please add it as a comment to above answers.
Hi,

javascript:window.location.href

This is javascript syntax to redirect page
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900