Tutorial :How to make a specific field wider within the gridview?



Question:

    <asp:BoundField DataField="ComputerModel" HeaderText="ComputerModel"       SortExpression="ComputerModel"       ItemStyle-Width="50px"/>        <asp:CheckBoxField DataField="Lease" HeaderText="Lease"           SortExpression="Lease" />      <asp:BoundField DataField="SerialNumber" HeaderText="SerialNumber"           SortExpression="SerialNumber" />      <asp:BoundField DataField="LeasedTagNum" HeaderText="LeasedTagNum"           SortExpression="LeasedTagNum" />      <asp:BoundField DataField="MonitorType" HeaderText="MonitorType"           SortExpression="MonitorType" />      <asp:BoundField DataField="MonitorCount" HeaderText="MonitorCount"           SortExpression="MonitorCount" />      <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />  </Fields>  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />  <EditRowStyle BackColor="#2461BF" />  <AlternatingRowStyle BackColor="White" />  


Solution:1

Try something like this:

<asp:BoundField DataField="ComputerModel" ItemStyle-Width="50px"/>  

where 50px is the width you need.


Solution:2

Try this:

<asp:BoundField DataField="ComputerModel" HeaderText="ComputerModel"           SortExpression="ComputerModel"           HeaderStyle-Width="50px" >  </asp:BoundField>  


Solution:3

Can we see all the HTML for the control? I'm curious to see the markup for the entire control so I don't make any assumptions.

Per MSDN try

 <asp:boundfield          sortexpression="LastName"          datafield="LastName"          headertext="LastName">            <itemstyle width="50px">            </itemstyle>        </asp:boundfield>  

I would like to see what you have thus far and maybe I can be more helpful. Also is there any CSS class that may be setting the item width?


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »