GridView1_RowDataBound导致网页无响应 [英] GridView1_RowDataBound causing web page not responding

查看:96
本文介绍了GridView1_RowDataBound导致网页无响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要我的gridview可点击,所以我使用的是GridView1_RowDataBound。但是当系统将大数据加载到gridview时,它会因为每次将1行数据加载到gridview时运行GridView1_RowDataBound而挂起。

如何使我的gridview cllickable但不会导致挂起?





我的代码如下所示:



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:

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") + "'";
     }

 }

推荐答案





试试这个



e.Row.Attributes.Add(onclick,javascript:window.location.href =''page.aspx ?ID =+ e.Row.Cells [0] .Text +'';);
Hi,

Try this

e.Row.Attributes.Add("onclick", "javascript:window.location.href =''page.aspx?ID=" + e.Row.Cells[0].Text + "'';");


在绑定大量数据时使用griview分页以及尝试ashokmmrk解决方案



--Sj
Use griview paging while binding large amount of data as well as try ashokmmrk solution

--Sj


谢谢!

你们介意解释为什么以下代码是更好?



e.Row.Attributes.Add(onclick,javascript:window.location.href =''page.aspx?ID =+ e .Row.Cells [0] .Text +'';);
Thank you!
Do u guys mind to explain why following code is better?

e.Row.Attributes.Add("onclick", "javascript:window.location.href =''page.aspx?ID=" + e.Row.Cells[0].Text + "'';");


这篇关于GridView1_RowDataBound导致网页无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆