Home > Forum > ASP.NET > Gridview Column Width Issue in Asp.Net

Gridview Column Width Issue in Asp.Net

by Narain Siddharth   on Feb 14, 2011   Category: ASP.NET  |  Views: 14134    |  Points: 5   |  Silver 
  Reply
Hi,

How to change/modify the gridview header width.

-Narain

Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :Gridview Column Width Issue in Asp.Net   
by Narain Siddharth
on Feb 14 2011 1:42AM
Points : 10
Silver 
Below is the sample code for gridview Header width and Item width
<asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" Runat="server"
DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="id"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundField HeaderText="ID" DataField="id" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="20px" ItemStyle-Width="20px"/>
<asp:BoundField HeaderText="First Name" DataField="au_fname" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="20px" ItemStyle-Width="20px"/>
<asp:BoundField HeaderText="Phone" DataField="phone" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="20px" ItemStyle-Width="20px"/>
<asp:BoundField HeaderText="City" DataField="city" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="20px" ItemStyle-Width="20px"/>
<asp:BoundField HeaderText="Start Date" DataField="s_Date" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50px" ItemStyle-Width="50px"/>
<asp:BoundField HeaderText="End Date" DataField="e_Date" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50px" ItemStyle-Width="50px"/>
</Columns>
</asp:GridView>

or else you can specify header and item width for each boundfield.
<asp:BoundField HeaderText="Start Date" DataField="s_date" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemStyle HorizontalAlign="Center" Width="50px" />
</asp:BoundField>


Regards,
Narain.
  Re :Gridview Column Width Issue in Asp.Net   
by groval mitch
on Apr 26 2015 11:46PM
Points : 10
Starter 
Simple Asp.Net Gridview tutorial step by step

http://asp.net-informations.com/gridview/asp-gridview.htm

Mitch

Recent Post

Latest Posts