Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Dear all
 
I want to width for every TemplateField in gridview
Is it possible ? If yes please revert
else
please tell me other solution for the same.
 
thanks..................
Posted 28-Apr-11 23:07pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

To set the column width for GridView, you can use the <HeaderStyle> or <ItemStyle> to set witdth for a template column.
 
Sample:
<asp:TemplateField HeaderText="used" SortExpression="used">
<HeaderStyle Width="100" />
<ItemStyle Width="100" />
 
<HeaderTemplate>
fjsfjkldsfksdjfdsfjfkksfsdkfdsjfjkfdsj
</HeaderTemplate>
 
<EditItemTemplate>
......
......
 
 
Details here: MSDN: Tutorial 12: Using TemplateFields in the GridView Control[^]
  Permalink  
Comments
Member 7894579 at 27-May-13 5:35am
   
thanks
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

if i click addnew linkbutton. i need to get empty row in the gridview.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

use ItemStyle-Width (ItemStyle-*)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try in this way.
 
<asp:TemplateField HeaderText="Name">
    <ItemTemplate>
           <asp:Label ID="lblCatId" runat="server" Text='<%#Eval("CatId") %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle Width="20%" />
   </asp:TemplateField>
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

you can set the width here is a simple example
 
<asp:TemplateField>
                                                <ItemStyle Width="7%" BorderColor="Dodgerblue" BackColor="white" HorizontalAlign="Left"/>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100