TonyReba
asked on
Gridview Item Template width
Can someone how can I define an static width for a gridview so the bound objects doesnt auto increase the width of the cells, ( Iam planning to have a fixed size of character on the textboxes)
Will this be done in CSS?
Will this be done in CSS?
<asp:gridview ID="Gridview2" runat="server" ShowFooter="True"
AutoGenerateColumns="False" onrowcreated="Gridview2_RowCreated"
EnableModelValidation="True">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField >
<HeaderTemplate >
<asp:Label ID="Label2" runat="server">NT-1</asp:Label>
<asp:TextBox ID="txt_Census19" runat="server" Width="50px" ></asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
Bed:
<asp:TextBox ID="txt_Bed19" runat="server" Width="50px"></asp:TextBox>
Status:
<asp:DropDownList ID="txt_Comment19" runat="server" AppendDataBoundItems="True"
style="text-align: left" >
<asp:ListItem value="0" text="Select"> </asp:ListItem>
<asp:ListItem>Assigned</asp:ListItem>
<asp:ListItem>Blocked Room</asp:ListItem>
<asp:ListItem>Open NS</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
For Template Field Column Use Code:
<asp:TemplateField >
<HeaderTemplate >
<asp:Label ID="Label2" runat="server">NT-1</asp:L abel>
<asp:TextBox ID="txt_Census19" runat="server" Width="50px" ></asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
<ItemStyle HorizontalAlign="Center" width="50px" />
<HeaderStyle cssclass="myGridHeader" HorizontalAlign="Center" ForeColor="White" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<HeaderTemplate >
<asp:Label ID="Label2" runat="server">NT-1</asp:L
<asp:TextBox ID="txt_Census19" runat="server" Width="50px" ></asp:TextBox>
</HeaderTemplate>
<ItemTemplate>
<ItemStyle HorizontalAlign="Center" width="50px" />
<HeaderStyle cssclass="myGridHeader" HorizontalAlign="Center" ForeColor="White" />
</ItemTemplate>
</asp:TemplateField>
ASKER
Could I do this with css , and defining this property on the Gridview only?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<asp:BoundField HeaderText="Header Text" DataField="Datafield" SortExpression="Datafield"
<ItemStyle HorizontalAlign="Center" width="50px" />
<HeaderStyle cssclass="myGridHeader" HorizontalAlign="Center" ForeColor="White" />
</asp:BoundField>