473,941 Members | 4,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting Proportional Width of Bound GridView

In a C#.NET web page, I'm using the GridView control bound to a
ObjectDataSourc e 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 4940
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*********@di scussions.micro soft.comwrote in message
news:O4******** ******@TK2MSFTN GP03.phx.gbl...
In a C#.NET web page, I'm using the GridView control bound to a
ObjectDataSourc e 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******** ******@TK2MSFTN GP02.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
8948
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
10295
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 following code on a button: Protected Sub Button1_Click(ByVal sender As Object, _
4
15466
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 another page, the widths are set as they should be. Going back to page one, the widths are still correct. Not a clue what's going on here!
2
11733
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
9168
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 file... Anyone got any tips about how to do this? Jeff
1
15055
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 to add controls dynamically as I am trying to write a reusable , general , spreadsheet like display control that can take advantage of the built- in update and delete features of the SqlDataSource/Gridview controls. This user control can get its...
2
4412
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 ItemStyle to 300 px and set Wrap to False for the HeaderStyle and ItemStyle. When I accept settings the "Notes" field widens in design mode but when I run the web site, the Notes field is back to default width. PS - My gridview is bound to...
1
1651
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 ItemStyle to 300 px and set Wrap to False for the HeaderStyle and ItemStyle. When I accept settings the "Notes" field widens in design mode but when I run the web site, the Notes field is back to default width. I've come across many articles and...
4
8024
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 try to do that it throws an error "Conversion from string "95%" to type 'Integer' is not valid." My code causing the error is below. Is there a work around? Thanks. David gvWeeklyPlanner.Width = "95%"
0
10134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9858
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6080
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6298
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.