473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Setting Proportional Width of Bound GridView

In a C#.NET web page, I'm using the GridView control bound to a
ObjectDataSource and the binding and data reading works fine. It auto
generates the columns from the SelectMethod and makes the drid wide enough
to show them all.

The problem comes when I have an asp:Panel control around the grid (to
generate scrollbars if the GridView is larger than the screen size).

It always make the encompassing control as wide as the GridView.

Now, I was under the assumption that if a Table element has a width of
"100%", that applies to the browser size, not the size of the content of the
table... Maybe that is my mistake.

If I set the Panel width explicitly, it all works OK, but then when I resize
the browser window, the panel doesn't resize (of course).

Does anyone know of a simple way to size an asp:Panel element so that it is
sized to the browser size, while the contents of the panel retain their own
fixed size (thereby forcing the creation of the scrollbars)?

TIA
Nov 23 '06 #1
3 4921
I'm afraid there is no way how to use proportional size (%) and scrollbars
together:( I have tried a lot and i wasn't a bit succesfull so i have
written javascript code which recalculate the size and set fixed width of
panel

Lukas

"Andrew Hayes" <An*********@discussions.microsoft.comwrote in message
news:O4**************@TK2MSFTNGP03.phx.gbl...
In a C#.NET web page, I'm using the GridView control bound to a
ObjectDataSource and the binding and data reading works fine. It auto
generates the columns from the SelectMethod and makes the drid wide enough
to show them all.

The problem comes when I have an asp:Panel control around the grid (to
generate scrollbars if the GridView is larger than the screen size).

It always make the encompassing control as wide as the GridView.

Now, I was under the assumption that if a Table element has a width of
"100%", that applies to the browser size, not the size of the content of
the table... Maybe that is my mistake.

If I set the Panel width explicitly, it all works OK, but then when I
resize the browser window, the panel doesn't resize (of course).

Does anyone know of a simple way to size an asp:Panel element so that it
is sized to the browser size, while the contents of the panel retain their
own fixed size (thereby forcing the creation of the scrollbars)?

TIA

Nov 23 '06 #2
Being a C# developer, I know next to nothing about Javascript, so could you post the js code you used to determine what width to set the Panel to? TIA
Dec 8 '06 #3
http://msdn.microsoft.com/workshop/a...lientWidth.asp

<Andrew Hayeswrote in message
news:eT**************@TK2MSFTNGP02.phx.gbl...
Being a C# developer, I know next to nothing about Javascript, so could
you post the js code you used to determine what width to set the Panel to?
TIA

Dec 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

258
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
5
by: Steve Bugden | last post by:
Hi, I would like to set the column widths in the ASP.NET GridView control at runtime I have tried the following: http://msdn2.microsoft.com/en-us/library/ms178296.aspx Which uses the...
4
by: Chuck | last post by:
I'm setting the column with for a gridview (25+- columns) and have paging turned on. When the gridview is first displayed, the column widths are all set to the default. But after paging to...
2
by: Jacksm | last post by:
How can I align an asp:table columns with gridview columns (the widths)? I have tried setting table.column(0).width = gridview.column(0).width at page_load but it doesn't work. Thanks in advance
8
by: Jeff | last post by:
ASP.NET 2.0 I have a webpage which contains a GridView. I want this GridView's HeaderTemplate to display the text "Inbox" or "Outbox"... So I think I need to set the value in the code behind...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
2
by: =?Utf-8?B?ZG1idXNv?= | last post by:
How do I increase the default width of a gridview column (just one column, the 10th column, named "Notes")? In design mode, I changed the width properties of the HeaderStyle, ControlStyle, and...
1
by: =?Utf-8?B?ZG1idXNv?= | last post by:
How do I increase the default width of a gridview column (just one column, the 10th column, named "Notes")? In design mode, I changed the width properties of the HeaderStyle, ControlStyle, and...
4
by: David C | last post by:
I am emailing a GridView and setting its Width property to 900 before rendering and it works great. However, when the rendering is done, I want to reset the Width back to 95% like it was. When I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.