Tuesday, September 15, 2009

Gridview and extra Div

Disclaimer: This post is to share info for people working on ASP.Net. There is no intention to defame or pass comments/remarks or criticize any person or organization.

MicroSoft did it again!

I have code working witin ASP-HTML-Javascript that dynamically shows a vertical scrollbar when the no. of rows exceed a configurable value.

<body onload=fnSetTableHeigh() >
<div>
<table id=tblDetails >
<--- Table rows >
</table>
</div>
</body>

This has been working without any issues in my ASP. Recently, I have added a new ASPX web page to the ASP.Net section of our application.

So, a GridView control is defined to display the data and I have used the same concept. GridView control should render a HTML table and so I enclosed it in a DIV expecting it to work –

<div id=divDetails>
<asp:GridView id=gvDetails & gt;

</asp:GridView>
</div>

But, it was not working. I thought it was an issue with my JS and tried to fix that function. No progress. Then, I tried to adjust various attributes of the gridview and div controls – but in vain.

After struggling for 2 hours, somehow I thought I should see what was getting rendered actually. To my horror, gridview is rendering extra div; The rendered code was –

<div id=divDetails>
<div>
<table id=tblDetails >
<--- Table rows >
</table>
</div>
</div>

This was OK until I saw the response on the site when this bug had been reported in 2006! They did not bother to fix this even in VS 2008, ASP.Net 3.5.

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=104139

For umpteenth time, I thought of banging my head for choosing MS technologies as my stream.

No comments:

Post a Comment