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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GridView - canShrink, canGrow??? PageSize?

Status
Not open for further replies.

randysmid

Programmer
Dec 12, 2001
801
US
Hi ALL,
Is there anything that I can do that will shrink or grow the size of my GridView, based on the number of rows?

For instance, I've set the PageSize to 7, but oftentimes I'll only have one row of data. Othertimes I might have 50 rows of data. Since I have other fields on the aspx form, I don't want to waste the space unless absolutely necessary.

Many thanks, Randy

 
You can do it in the codebehind...

if (gridview1.rows.count = ??)
{
gridview1.wodth = ??;
}
 
if it is going to go off the page then you can put it into a panel and build it dynamically like this.

gridview x = new gridview;
panel p = new panel;

x.cssclass = "Style";
x.datasource = data;
x.databind();

p.controls.add(x);

//In the style sheet

.Style
{
Overflow:auto;
height:300;
width:500;
}

Then your grid will have a scroll bar when it grows past your set size
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top