Search code examples
asp.netstylesboundfield

Asp:BoundField how to force input width


Silly question...

Code:

<asp:BoundField DataField="PrevDuration" HeaderText="Prev." 
            SortExpression="PrevDuration" ItemStyle-Width="25">
        </asp:BoundField>

Html output:

<td style="width:25px;"><input name="ctl00$MainContent$GridView1$ctl03$ctl02" type="text" value="1" size="5" title="Prev."></td>

So this code specifies the td width, but how instead can I specify the input width?

PS. by the way where does that size=5 comes out from?


Solution

  • Use ControlStyle-Width="25px" property.

    <asp:BoundField DataField="PrevDuration" HeaderText="Prev." SortExpression="PrevDuration" ControlStyle-Width="25px">
    </asp:BoundField>