jos*_*ick 17 .net c# asp.net gridview
我有一个可以编辑的GridView.我的问题是当我单击编辑时,文本框太小(File Name
列).它不足以显示其内容,并且不如列的其余部分宽.
如何让文本框更宽广?
这是ASP代码:
<asp:GridView ID="FileGridView" runat="server" AllowPaging="True" OnPageIndexChanging="FileGridView_PageIndexChanging"
CellPadding="1" CssClass="GridView" GridLines="Horizontal"
Width="100%" AutoGenerateColumns="false"
AutoGenerateEditButton="true"
OnRowCancelingEdit="GridView_RowCancelingEdit" OnRowEditing="GridView_RowEditing" OnRowUpdating="GridView_RowUpdating"
>
<Columns>
<asp:BoundField DataField="Name" HeaderText="File Name" />
<asp:BoundField DataField="Length" HeaderText="Size" ReadOnly="true" />
<asp:BoundField DataField="LastWriteTime" HeaderText="Last Modified" ReadOnly="true" />
</Columns>
<RowStyle CssClass="GridViewRow" />
<EditRowStyle ForeColor="Black" CssClass="GridViewEditRow" />
<SelectedRowStyle Font-Bold="True" CssClass="GridViewSelectedRow" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle CssClass="GridViewHeader" ForeColor="White" />
<AlternatingRowStyle CssClass="GridViewAlternatingRow" />
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
这背后有C#代码来更新数据,这很好用.我希望解决方案是在ASP中,但如果解决方案需要一些C#代码,那对我来说没关系.
lin*_*lnk 15
您可以将CSS类应用于控件,如下所示:
<asp:BoundField DataField="Name" HeaderText="File Name"
ControlStyle-CssClass="wide" />
Run Code Online (Sandbox Code Playgroud)
然后width
在StyleSheet中设置:
input.wide { width: 100px; }
Run Code Online (Sandbox Code Playgroud)
这应该工作:
<asp:BoundField DataField="Name" HeaderText="File Name" />
<controlstyle Width="200">
</controlstyle>
</asp:BoundField>
Run Code Online (Sandbox Code Playgroud)
您必须ItemStyle-Width
为列和ControlStyle-Width
列内的控件设置 :
<asp:BoundField DataField="Name" HeaderText="File Name" />
<ItemStyle Width="200px" />
<ControlStyle Width="100%" />
</asp:BoundField>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24148 次 |
最近记录: |