Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview, scrollbar, changing width dynamically 1

Status
Not open for further replies.

wimani

Programmer
Jan 6, 2008
4
US
I have added a scrollbar (<div style="OVERFLOW: auto; HEIGHT: 250px">) to my gridview so that if the PageSize exceeds 10 rows the user can use the scrollbar. The width of the table that embeds the gridview is 925px and the width of the gridview is 912px where 13px is being left for the scrollbar.

What I'm trying to figure out is that when the grid has 10 or less rows the width of the gridview should be 925px so there isn't 13 px of space left and when there are more 10 rows the width of the grid should be 912 px leaving room for the scrollbar.

What I thought I could do is in the unload event of the gridview have a condition that checks the count of the rows and if the pagesize exceeds 10 rows then set the width of the gridview to 912 else set the width to 925. Unfortunately, that doesn't work.

So any suggestions will be appreciated.

protected void gvCallDetails_Unload(object sender, System.EventArgs e)
{

if (gvCallDetails.Rows.Count > 10)
{

gvCallDetails.Width = 912;

}

else

{

gvCallDetails.Width = 925;

}

}

 
Try using the RowDataBound event and setting the CssClass of the GridView. All the styling should be contained in a css file anyway which will make it easier to modify.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top