473,903 Members | 5,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview and Setting column width problem

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!

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100;
left: 0px; position: absolute; top: 103px; width:2900; "
SkinID="GridSki n" DataSourceID="S qlDataSource1"
AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="True" PageSize="4" >
<Columns>
<asp:BoundFie ld DataField="Floo d" HeaderText="Flo od"
SortExpression= "Flood" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
.............

Any ideas about what I'm missing??

chuck

Aug 28 '06 #1
4 15456
I had a problem similar to this. I found that, unlike other style settings,
custom column widths get reset on each postback with the
GridView control. I solved the problem by reseting them on each postback in
the Page_Load event before my !IsPostBack test. I could
have also put that in OnInit I suppose.

I don't know if this is a bug or by design.
--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com

"Chuck" <ch**********@g mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
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!

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100;
left: 0px; position: absolute; top: 103px; width:2900; "
SkinID="GridSki n" DataSourceID="S qlDataSource1"
AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="True" PageSize="4" >
<Columns>
<asp:BoundFie ld DataField="Floo d" HeaderText="Flo od"
SortExpression= "Flood" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
............

Any ideas about what I'm missing??

chuck

Aug 28 '06 #2
arrrrrrgh. I tried the page_load before the is_postback.
No change.

Adding "TABLE { table-layout:fixed; }" to the css file solved the
problem for me, but created another. Now the paging numbers are
justified across the page, instead of being grouped to the left. Wish
I could figure out what I'm doing wrong.

chuck
GaryDean wrote:
I had a problem similar to this. I found that, unlike other style settings,
custom column widths get reset on each postback with the
GridView control. I solved the problem by reseting them on each postback in
the Page_Load event before my !IsPostBack test. I could
have also put that in OnInit I suppose.

I don't know if this is a bug or by design.
--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com

"Chuck" <ch**********@g mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
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!

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100;
left: 0px; position: absolute; top: 103px; width:2900; "
SkinID="GridSki n" DataSourceID="S qlDataSource1"
AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="True" PageSize="4" >
<Columns>
<asp:BoundFie ld DataField="Floo d" HeaderText="Flo od"
SortExpression= "Flood" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
............

Any ideas about what I'm missing??

chuck
Aug 29 '06 #3
I'm wondering if the Page_Load event is getting executed each time the user
changes pages. You could put a stop on that code to see.

--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com
"Chuck" <ch**********@g mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
arrrrrrgh. I tried the page_load before the is_postback.
No change.

Adding "TABLE { table-layout:fixed; }" to the css file solved the
problem for me, but created another. Now the paging numbers are
justified across the page, instead of being grouped to the left. Wish
I could figure out what I'm doing wrong.

chuck
GaryDean wrote:
>I had a problem similar to this. I found that, unlike other style
settings,
custom column widths get reset on each postback with the
GridView control. I solved the problem by reseting them on each postback
in
the Page_Load event before my !IsPostBack test. I could
have also put that in OnInit I suppose.

I don't know if this is a bug or by design.
--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com

"Chuck" <ch**********@g mail.comwrote in message
news:11******* *************** @p79g2000cwp.go oglegroups.com. ..
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!

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100;
left: 0px; position: absolute; top: 103px; width:2900; "
SkinID="GridSki n" DataSourceID="S qlDataSource1"
AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="True" PageSize="4" >
<Columns>
<asp:BoundFie ld DataField="Floo d" HeaderText="Flo od"
SortExpression= "Flood" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
............

Any ideas about what I'm missing??

chuck

Aug 29 '06 #4
Yep, the page load is executed when the page loads, and the column,
Item and Header widths are being set. But if I don't have the css
command: TABLE { table-layout:fixed; }, then the column widths are not
set.

But with the css command the widths are set, but the pager line is
justified across the table (which is quite wide).

If there a css command to set the footer for the table??

Wierd.

chuck

GaryDean wrote:
I'm wondering if the Page_Load event is getting executed each time the user
changes pages. You could put a stop on that code to see.

--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com
"Chuck" <ch**********@g mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
arrrrrrgh. I tried the page_load before the is_postback.
No change.

Adding "TABLE { table-layout:fixed; }" to the css file solved the
problem for me, but created another. Now the paging numbers are
justified across the page, instead of being grouped to the left. Wish
I could figure out what I'm doing wrong.

chuck
GaryDean wrote:
I had a problem similar to this. I found that, unlike other style
settings,
custom column widths get reset on each postback with the
GridView control. I solved the problem by reseting them on each postback
in
the Page_Load event before my !IsPostBack test. I could
have also put that in OnInit I suppose.

I don't know if this is a bug or by design.
--
Regards,
Gary Blakely
Dean Blakely & Associates
www.deanblakely.com

"Chuck" <ch**********@g mail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
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!

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100;
left: 0px; position: absolute; top: 103px; width:2900; "
SkinID="GridSki n" DataSourceID="S qlDataSource1"
AutoGenerateCol umns="False"
AllowPaging="Tr ue" AllowSorting="T rue"
EnableSortingAn dPagingCallback s="True" PageSize="4" >
<Columns>
<asp:BoundFie ld DataField="Floo d" HeaderText="Flo od"
SortExpression= "Flood" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
............

Any ideas about what I'm missing??

chuck
Aug 29 '06 #5

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

Similar topics

0
2217
by: hammad.awan_nospam | last post by:
Hello, I am using ASP.NET 2.0. What I have done is nested a gridview inside another column of a gridview using a template data field column declaritively in my web form. Inside this child gridview I have set an ItemStyle property of width 20% for the first templated field which contains a hyperlink control, and an ItemStyle of width 80% for the second templated field which contains a label. Both of these controls are databound to...
1
9364
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
5
10293
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, _
1
2898
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding properties and Item Style to the column but it has no effect. Is there someway to size this column to be smaller? I removed the CssClass property and it had no effect on the size as well. 2. The gridview is sortable using javascript. Is there...
2
11729
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
0
2445
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from a data view (which in turn is loaded from a manually setup DataTable for testing purposes). One of the columns in the grid is a checkbox that's tied to an event handler that'll change the .Visible property of a column with a text box. That text...
1
6744
by: Jeff | last post by:
ASP.NET 2.0 I've got problems with the right column in my GridView. The GridView consist of 2 columns, the problem column is the column on the right side. The problem is that it looks like there is a huge space between the 2 columns, see the huge grey space between the 2 columns. I want the columns to be very close to each other with only 10px open space between the columns. Now it looks like there is a 160px margin between them
5
54731
by: mohaaron | last post by:
OK, I have now gone through lots of posts, and there are lots, looking for a anwer as to why I can't set the width of the columns in my gridview. So far I have tried the following methods to set the width and nothing works. 1. <asp:BoundField HeaderText="fieldName" ItemStyle-Width="300px" DataField="fieldName" /> 2. <asp:BoundField HeaderText="fieldName" HeaderStyle-Width="300px" DataField="fieldName" /> 3. This has been tried in both...
4
25544
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the columns collection. I modified the RowCreated even to gridview, and I can change properties on the cells, but not width. (setting tooltip, background color, etc, all work but changing width has no effect). Here's sample code I am using:
0
11282
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
10873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10500
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
9684
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...
0
7206
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
5894
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...
1
4726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.