【问题标题】:Asp:BoundField how to force input widthAsp:BoundField如何强制输入宽度
【发布时间】:2013-05-07 05:11:19
【问题描述】:

愚蠢的问题...

代码:

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

HTML 输出:

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

所以这段代码指定了 td 宽度,但是我该如何指定 input 宽度呢?

附言。顺便问一下 size=5 是从哪里来的?

【问题讨论】:

  • 成功了吗?还是您需要其他解决方案?

标签: asp.net styles boundfield


【解决方案1】:

给它一个cssclass并在那里设置宽度

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

CSS

.inputs{
   width:...px;
}

【讨论】:

    【解决方案2】:

    使用ControlStyle-Width="25px" 属性。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 2014-12-19
      • 2018-05-17
      • 2019-02-25
      相关资源
      最近更新 更多