Theming the ControlStyle for BoundField controls within data presentation controls.

Hi all,

I was wondering if you can set a default width for template fields and/or BoundField controls within a GridView or  DetailsView / FormView controls? I can change the control widths of bound data control fields, including template fields, by setting the ControlStyle. But if I have a bunch of fields in a DetailsView control for example, it's a pain to have to set the ControlStyle property for each field. I would like to do it in one fell swoop.

If I add the following to my skin file, then I get server control rendering errors on my pages. The controls can't be rendered becuase I get parsing errors. The following is illegal.

 

<asp:TemplateField>
	<ControlStyle Width="150px" />
</asp:TemplateField>

<asp:BoundField>
	<ControlStyle Width="150px" />
</asp:BoundField>

 Is there a way to do this?

Thanks,

Andy


Nothin' but net, .NET that is...Microsoft is freakin' sweet!!!
0
andeezlemoyo
8/14/2006 12:37:28 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
1183 Views

Similar Articles

[PageSpeed] 2

Hi,andeezlemoyo:

<asp:GridView runat="server" CssClass="DataWebControlStyle">
   <AlternatingRowStyle CssClass="AlternatingRowStyle" />
   <RowStyle CssClass="RowStyle" />
   <HeaderStyle CssClass="HeaderStyle" />  
   <SelectedRowStyle CssClass="SelectedRowStyle" />

<ControlStyle Width="150px">
</asp:GridView>

In you Skin file.

 




Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

This posting is provided "AS IS" with on warranties, and confers no rights.
0
rexlin
8/14/2006 3:21:38 AM

Hi rexlin,

Thanks for your input but it's not working for me. I get parsing errors when I try it that way too.

Can you test it and see if it works for you?

-Andy


Nothin' but net, .NET that is...Microsoft is freakin' sweet!!!
0
andeezlemoyo
8/15/2006 9:49:48 AM

<asp:GridView runat="server">
<Columns>
  <asp:TemplateField >
     <ControlStyle Width="150px"/>             
   </asp:TemplateField>
   </Columns>
</asp:GridView>

 

Here it is.




Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

This posting is provided "AS IS" with on warranties, and confers no rights.
0
rexlin
8/16/2006 1:17:21 AM

Rex,

All that does is insert a blank column in my gridview controls depending on where I place it in my skin file (within the gridview tag) .

Have you tested it? Are sure it works?

-Andy


Nothin' but net, .NET that is...Microsoft is freakin' sweet!!!
0
andeezlemoyo
8/16/2006 3:13:09 AM

Andy, 

As <Columns> is collection, skin file customization act as: "replaces the collection in its entirety when using Themes and merges the collection when using StyleSheetThemes" per http://quickstarts.asp.net/QuickStartv20/aspnet/doc/themes/fileformat.aspx "Theming Control Collections".

However, you can proceed the following scenario for default width assignment:

  1. Make the css class definition for control header in skin file like:
    <HeaderStyle CssClass="GridHeader" />
  2. At css file make something like:
    .GridHeader th {
       width: 150px;
    }

To change default use HeaderStyle-Width="xxxpx" for asp:TemplateField...

Hope this will help...

 

0
Petr
9/6/2007 11:04:24 PM
Reply: