DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us