asp.net网格视图绑定字段更改宽度

时间:2013-07-16 13:15:35

标签: asp.net gridview

我正在asp.net页面上工作。我在其中使用网格视图。我希望能够更改绑定字段的宽度。我在用  ControlStyle-Width="100px"itemstyle-width,但我无法更改边界字段的宽度。谁能告诉我这是怎么做到的?

  <asp:BoundField DataField="ptDob" HeaderText="PatientDob" HeaderStyle-HorizontalAlign="Left" SortExpression="ptDob" ControlStyle-Width="2500px"  />
                <asp:BoundField DataField="memid" HeaderText="MemberId" HeaderStyle-HorizontalAlign="Left"  ControlStyle-Width="100px"
                    SortExpression="memid" />
                <asp:BoundField DataField="memssn" HeaderText="MembeSsn" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="memssn" />
                <asp:BoundField DataField="billType" HeaderText="BillType" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="billType" />
                <asp:BoundField DataField="insuranceName" HeaderText="insuranceName" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="insuranceName" />
                <asp:BoundField DataField="taxId" HeaderText="TaxId" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="taxId" />
                <asp:BoundField DataField="attendingProvider" HeaderText="AttendingProvider" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="attendingProvider" />
                <asp:BoundField DataField="parStatus" HeaderText="parStatus" HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="100px"
                    SortExpression="parStatus" />
                <asp:BoundField DataField="admittedDate" HeaderText="AdmittedDate" HeaderStyle-HorizontalAlign="Left"
                    SortExpression="admittedDate" />
                <asp:BoundField DataField="billedAmount" HeaderText="BilledAmount" HeaderStyle-HorizontalAlign="Left"

3 个答案:

答案 0 :(得分:1)

ItemStyle-Width="100px"HeaderStyle-Width="100px"应该完美无缺,也许你还有其他风格干扰,CSS也许。

答案 1 :(得分:1)

您可以在itemstyle中将其添加为CSS字段。然后确保该类具有宽度设置。假设你没有任何优先的内联样式,那么这将有效。

<asp:BoundField DataField="parStatus" HeaderText="parStatus">
    <ItemStyle CssClass="yourclass"></ItemStyle>
</asp:BoundField>

答案 2 :(得分:0)

尝试在类add

中使用HeaderText-cssClass
padding-left: 100px;
padding-right: 100px;