|
|
|
start date: Wed, 22 Aug 2007 19:41:45 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
tshad
|
|
2
marss
|
Dynamically changing styles in DataGrid
I am trying to build a datagrid that is customizable by my clients.
I can hide and show columns or changes sizes of the Columns or DataGrid
itslef from the Page_PreRender event that works pretter well.
DataGrid1.Width = new Unit("551px")
for each col as DataGridColumn in DataGrid1.Columns
if col.HeaderText = "Company" orElse col.HeaderText = "Posted" then
col.Visible = false
end if
next
The sizing of the DataGrid (shown above) only works if the size is set by
"Width", ie:
<anthem:DataGrid
Visible=true
AllowSorting="false"
AutoGenerateColumns="false"
CellPadding="0"
CellSpacing="0"
ID="DataGrid2"
runat="server"
ShowFooter="false"
ShowHeader="true"
OnSortCommand="SortDataGrid"
BorderWidth="0"
BorderColor="#999999"
Width="701px"
style="padding-right:5px">
If, however, I tried to use a style - the style seems to get applied AFTER
the PreRender event, ie:
<anthem:DataGrid
Visible=true
AllowSorting="false"
AutoGenerateColumns="false"
CellPadding="0"
CellSpacing="0"
ID="DataGrid2"
runat="server"
ShowFooter="false"
ShowHeader="true"
OnSortCommand="SortDataGrid"
BorderWidth="0"
BorderColor="#999999"
style="padding-right:5px;width=701px">
In this example, the size of the table would be 701px instead of the 551px I
changed it to in the PreRender. The first example works fine:
How can I do this in the PreRender section (or another area) if the size is
set in a style?
Thanks,
Tom
Date:Wed, 22 Aug 2007 19:41:45 -0700
Author:
|
Re: Dynamically changing styles in DataGrid
On 23 , 05:41, "tshad" wrote:
> How can I do this in the PreRender section (or another area) if the size is
> set in a style?
If width is set by means of style then change style.
DataGrid1.Style["width"] = "551px";
Regards,
Mykola
http://marss.co.ua
Date:Thu, 23 Aug 2007 01:51:53 -0700
Author:
|
|
|