Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2009, 02:40 AM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default setting the gridview width

i want to set the gridview with to fit a webpage ie1024*768
the gridview width is set to 100%.
but the grid view is displayed only o 75% of the page width
i want to knw how culd i set the column width to fit the column heading name and gridwidth to fit the page

i had earlier set the width of
<ItemStyleCssClass="data"/>
removed it and set the width of
<HeaderStyleCssClass="gridview"/>
but not got as needed

all in design time
culd anybody help me
 
Old January 14th, 2009, 01:32 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Is simply setting the width not working for you?

Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
          DataKeyNames="ID" DataSourceID="SqlDataSource1" Width="100%">
This should stretch the gridview to fill the viewport, unless the gridview is inside a container which is set to a smaller width. In that case, it would only stretch to fit the container.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old January 15th, 2009, 03:20 AM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<asp:GridViewid="GridView1"runat="server"HorizontalAlign="Center"GridLines="None"ForeColor="Black"PageSize="50"AutoGenerateColumns="False"AllowSorting="True"AllowPaging="True"Width="100%">

this is the grid view i am having and its not in any container

went thr' the code yest and found out why its not fitting the page . need a solution to fit the grid for some different code
the grid view is bound to database at design time
i am creating a row above header row or say one more header row at run time in which i want to add some buttons/images etc along with page nos and first/previous etc.....

wht i have done is taken the column count of grid and added that many columns above the actual header row
the prblm is

suppose i have 10 columns in my grid view a new row is added above the header row with 10 columns and the grid fit prefectly to the page width

but i want 12 columns in my new header row and
using the for loop and taking the grid column count+2 i can add more 2 columns
but the problem is due to increase in the above column no the actual grid with data appears shifted in and not fitting the grid.

i want
though the no of above columns increases the below grid along with the above column shld fit in a page

or in short how do i create one more header row above teh actual header row
 
Old January 15th, 2009, 02:22 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Are you saying that you want a header row that has more columns than the grid has?

If so, that is going to structure the table so that the main gridview won't span that row.

If you want to do this, I would add a new row with one column, and use the columnspan attribute to make it fit the grid. Then just freeform-place the controls you need, or place them in a new table inside that row with the number of columns you want.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old January 16th, 2009, 03:39 AM
Registered User
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i just deleted all and created it at design time as it was giving lots of problems
just want to knw how do i set the column width static at design time which will work even in run time





Similar Threads
Thread Thread Starter Forum Replies Last Post
Table: width setting for a cell Venki XSLT 2 July 14th, 2008 09:05 AM
How can i fix width (GridView) divekar.vishal ASP.NET 2.0 Professional 1 April 18th, 2008 09:43 AM
Setting the Logical Page Width mitchm Crystal Reports 0 May 24th, 2007 06:03 PM
Setting Column width in Datagrid anita General .NET 2 April 13th, 2005 02:25 AM
Setting Column Width r_ganesh76 Excel VBA 2 February 2nd, 2005 06:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.