Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

ASP.net GridView TemplateField width

Hi

I am trying to widen my first template field to 600 as shown below but the field seems to                                   <HeaderStyle Width="600px" />
remain the same narrow size

            <asp:GridView ID="GridView_Questions" runat="server" BackColor="White"
                BorderColor="#3366CC" BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
                Height="147px" Visible="False" Width="795px">
                <Columns>
       
                               <asp:TemplateField HeaderText="Question">

                               </asp:TemplateField>

I also tried the following which didn't work either
            <asp:GridView ID="GridView_Questions" runat="server" BackColor="White"
                BorderColor="#3366CC" BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
                Height="147px" Visible="False" Width="795px">
                <Columns>
       
                               <asp:TemplateField HeaderText="Question" ControlStyle-Height="220"
            ControlStyle-Width="700">
                                   <ControlStyle Height="220px" Width="700px" />
                                   <HeaderStyle HorizontalAlign="Left" />

                               </asp:TemplateField>
ASP.NET

Avatar of undefined
Last Comment
Murray Brown
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

What you are doing should probably work, but I set the theme for my gridviews in a .skin file that work for me.

<asp:GridView CellPadding="5" AutoGenerateColumns="False" GridLines="Horizontal" runat="server" BorderColor="Black"
        BorderStyle="Solid" BorderWidth="1" ForeColor="#333333" Font-Names="Verdana"
        EnableSortingAndPagingCallbacks="True" AllowPaging="True" AllowSorting="True" >
    <PagerSettings Position="TopAndBottom" PageButtonCount="20" />
    <RowStyle BackColor="#ffffff" BorderStyle="Solid" BorderWidth="1px" BorderColor="Black" Font-Size="10px" />
    <AlternatingRowStyle BackColor="#e8e8e8" HorizontalAlign="Left" />
    <FooterStyle BackColor="#6699FF" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="Black" Font-Bold="True" />
    <HeaderStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="10px"/>
    <FooterStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="11px" Font-Bold="True"/>
    <EditRowStyle BackColor="#FFFF99" ForeColor="Black" Font-Bold="True" />
    <EmptyDataTemplate>
        <center> -- No Records Found -- </center>
    </EmptyDataTemplate>
</asp:GridView>

However I have a few properties in my CSS file that didn't seem to work in the .skin file:

.gridview
      {
            font-size:0.75em;
            width:90%;
      }
      
      .gridview tr
      {
            font-size:0.95em;
            height:auto;
      }
      
      .gridview td
      {
            font-size:1.15em;
      }
      .gridview caption
      {
            text-align:left;
            font-size:0.85em;
            font-weight:bold;
            font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
            padding: 2px;
            color:Black;
            background-color: #DCEDE5;
            border:solid 1px black;
      }
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

A couple of other things I have in my .skin file for gridviews:

<asp:GridView SkinId="NoEmptyTemplate" CellPadding="5" AutoGenerateColumns="False" GridLines="Horizontal" runat="server" BorderColor="Black"
        BorderStyle="Solid" BorderWidth="1" ForeColor="#333333" Font-Names="Verdana"
        EnableSortingAndPagingCallbacks="True" AllowPaging="True" AllowSorting="True">
    <PagerSettings Position="TopAndBottom" PageButtonCount="20" />
    <RowStyle BackColor="#ffffff" BorderStyle="Solid" BorderWidth="1px" BorderColor="Black" Font-Size="10px" />
    <AlternatingRowStyle BackColor="#e8e8e8" HorizontalAlign="Left" />
    <FooterStyle BackColor="#6699FF" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="Black" Font-Bold="True" />
    <HeaderStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="10px"/>
    <FooterStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="11px" Font-Bold="True"/>
    <EditRowStyle BackColor="#FFFF99" ForeColor="Black" Font-Bold="True" />
 </asp:GridView>

<asp:GridView SkinID="noAlternateRows" CellPadding="5" AutoGenerateColumns="False" GridLines="Horizontal" runat="server" BorderColor="Black"
        BorderStyle="Solid" BorderWidth="1" ForeColor="#333333" Font-Names="Verdana"
        EnableSortingAndPagingCallbacks="True" AllowPaging="True" AllowSorting="True">
    <PagerSettings Position="TopAndBottom" PageButtonCount="20" />
    <RowStyle BackColor="#ffffff" BorderStyle="Solid" BorderWidth="1px" BorderColor="Black" Font-Size="10px" />
    <FooterStyle BackColor="#6699FF" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="Black" Font-Bold="True" />
    <HeaderStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="10px"/>
    <FooterStyle BackColor="#DCEDE5" ForeColor="Black" Font-Size="11px" Font-Bold="True"/>
    <EditRowStyle BackColor="#FFFF99" ForeColor="Black" Font-Bold="True" />
    <EmptyDataTemplate>
        <center> -- No Records Found -- </center>
    </EmptyDataTemplate>
</asp:GridView>
ASKER CERTIFIED SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Murray Brown
Murray Brown
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks very much
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo