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 29-Apr-11 0:07am
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
Member 11123172 at 31-Oct-14 7:54am
   
thanks for code project
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  
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  

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

  Print Answers RSS
0 OriginalGriff 288
1 ProgramFOX 165
2 Peter Leow 130
3 Sergey Alexandrovich Kryukov 125
4 Fredrik Bornander 85
0 OriginalGriff 288
1 ProgramFOX 165
2 Peter Leow 130
3 Sergey Alexandrovich Kryukov 95
4 Fredrik Bornander 85


Advertise | Privacy | Mobile
Web01 | 2.8.150301.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2015
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