467,905 Members | 1,902 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,905 developers. It's quick & easy.

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="GridSkin" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" PageSize="4" >
<Columns>
<asp:BoundField DataField="Flood" HeaderText="Flood"
SortExpression="Flood" HtmlEncode="False" >
<ItemStyle HorizontalAlign="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
.............

Any ideas about what I'm missing??

chuck

Aug 28 '06 #1
  • viewed: 14853
Share:
4 Replies
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**********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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="GridSkin" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" PageSize="4" >
<Columns>
<asp:BoundField DataField="Flood" HeaderText="Flood"
SortExpression="Flood" HtmlEncode="False" >
<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**********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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="GridSkin" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" PageSize="4" >
<Columns>
<asp:BoundField DataField="Flood" HeaderText="Flood"
SortExpression="Flood" HtmlEncode="False" >
<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**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.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**********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googleg roups.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="GridSkin" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" PageSize="4" >
<Columns>
<asp:BoundField DataField="Flood" HeaderText="Flood"
SortExpression="Flood" HtmlEncode="False" >
<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**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.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**********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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="GridSkin" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True"
EnableSortingAndPagingCallbacks="True" PageSize="4" >
<Columns>
<asp:BoundField DataField="Flood" HeaderText="Flood"
SortExpression="Flood" HtmlEncode="False" >
<ItemStyle HorizontalAlign="Center" Width="50px" />
<HeaderStyle Width="50px" />
</asp:BoundField>
............

Any ideas about what I'm missing??

chuck
Aug 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by hammad.awan_nospam | last post: by
5 posts views Thread by Steve Bugden | last post: by
1 post views Thread by Bill44077 | last post: by
2 posts views Thread by Jacksm | last post: by
1 post views Thread by Jeff | last post: by
5 posts views Thread by mohaaron | last post: by
4 posts views Thread by Yin99 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.