Reputation: 3000
I have grid view and now i want to set specific width for each cell and i tried my best to set width of each cell but failed to do so...
here is code that i applied to my template field.
<ItemTemplate>
<asp:Label ID="lblempid" runat="server" Text='<%#Eval("EmployeeId") %>'></asp:Label>
<ControlStyle Height="10px" Width="20px" />
</ItemTemplate>
I am new in c# and ASP.Net so please guide me.
thanks in advance. :)
Upvotes: 0
Views: 1389
Reputation: 176886
You can set like this
<asp:GridView ID="GridView1" runat="server">
<HeaderStyle Width="10%" />
<RowStyle Width="10%" />
<FooterStyle Width="10%" />
<Columns>
<asp:BoundField HeaderText="Name" DataField="LastName"
ItemStyle-Width="10%"
/>
</Columns>
</asp:GridView>
or
int colWidth = 100;
if (colWidth > 0)
{
for (int i = 0; i < GridView1.Columns.Count; i++)
{
GridView1.Columns[i].ItemStyle.Width = colWidth;
}
}
}
Upvotes: 2