Solved

ASP.net GridView TemplateField width

Posted on 2014-01-06
4
934 Views
Last Modified: 2014-01-06
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>
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39759286
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;
      }
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39759290
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>
0
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 500 total points
ID: 39759292
I also set individual template fields using CSS as well.
0
 

Author Closing Comment

by:Murray Brown
ID: 39759426
Thanks very much
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question