c# - gridview 列宽未在绑定(bind)字段中的 asp.net 中设置

标签 c# css asp.net gridview

我需要设置第一列宽度的最大尺寸,但它没有设置。同时将更多数据扩展。

 <div style="width:640px">
 <table style="width:640px">
    <asp:GridView ID="gvChallan" runat="server" AutoGenerateColumns="false" HeaderStyle-BackColor="#cccccc" Width="646px" >
        <HeaderStyle Width="222px" />
        <Columns>
            <asp:BoundField DataField="itemsdescription" HeaderText="Items/ Description" HtmlEncode="false" HeaderStyle-Width="222px" />
       <asp:BoundField DataField="Quantity" HeaderText="QTY" ItemStyle-Width="10%" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="center" /> 
       <asp:BoundField DataField="TotalBoxes" HeaderText="Total Boxes" ItemStyle-Width="10%" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="center" /> 
            </Columns>
    </asp:GridView>
     </table>
     </div>

最佳答案

使用 HeaderStyle-Width 而不是 ItemStyle-Width 如下所示。还设置 Grid 本身的全宽

<asp:BoundField DataField="itemsdescription" HeaderText="Items/ Description" HtmlEncode="false" HeaderStyle-Width="222px"  />

关于c# - gridview 列宽未在绑定(bind)字段中的 asp.net 中设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35504176/

相关文章:

c# - 基于值的 XSL 匹配元素

c# - 尝试读取或写入 protected 内存。当我调用 openfileDialog 的 showDialog 方法时

c# - 在 C# 中设置电子邮件附件名称

javascript - ASP.NET hiddenField 使用 ClientID 获取值(value),就像使用 javascript 使用母版页一样

html - 如何删除在移动菜单上使用 Twitter Bootstrap 时出现的水平滚动条

asp.net - html 5 文档类型和更旧的浏览器

html - 将鼠标悬停在菜单上会显示每个菜单中的下拉菜单列表

javascript - 当关闭屏幕菜单打开时,基础使箭头与其他类切换

c# - 如何在jquery中独立于浏览器捕获精确的td值

asp.net - 在 ASP.Net Core 中禁用 Accept-Language header 的默认使用