Groups | Blog | Home
all groups > asp.net datagrid control > december 2005 >

asp.net datagrid control : Why Soo Slow ?



Jay
12/5/2005 10:20:31 PM
ASP.NET 2.0.

One line of code (checkbox onclick) in a databound grid really slows down
the page load...

<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkEmp" onClick=<%# "HighlightRow(this, """ +
Eval("empname") + """)"%> runat="server" autopostback="False"/>
</ItemTemplate>
</asp:TemplateColumn>

If I remove the """ + Eval("employee_name") + """ part from the line
everything works great. Any ideas? Even the HighlightRow javascript
function is simple...

<script language="javascript">
<!--
function HighlightRow(chkB, empname)
{
xState=chkB.checked;
if(xState)
{
chkB.parentElement.parentElement.style.backgroundColor='yellow';
}
else
{
chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
}
}
-->
</script>

You may notice that the empname var is not eve used (yet) in the javascript.

Anyways, why would this take soo long for the page to load with the onclick
in place?

Thanks.

Chris Crowe [MVP 1997 -> 2006]
12/6/2005 8:45:16 PM
Becuase each row of the grid the code is evaluated - this can be slow.

You may be better to use a different method.

Check with an ASP.NET newsgroup for ASP.NET Gurus

--

Cheers

Chris Crowe [IIS MVP 1997 -> 2006]
http://blog.crowe.co.nz
------------------------------------------------


[quoted text, click to view]

Chris Crowe [MVP 1997 -> 2006]
12/6/2005 8:47:42 PM
Sorry I thought I was in an IIS Newsgroup.

--

Cheers

Chris Crowe [IIS MVP 1997 -> 2006]
http://blog.crowe.co.nz
------------------------------------------------


"Chris Crowe [MVP 1997 -> 2006]" <IISMVP2005@iisfaq.homeip.net> wrote in
message news:eVS$Akj%23FHA.140@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button