您好,我正在尝试在 ASP 中修复我的 Gridview,以便根据单元格数据使列更大。
这是它的样子:
http://s18.postimg.org/hjw6dwrmh/Capture.png
这是我用于此 Gridview 的代码:
<asp:GridView ID="GridView1" runat="server" CellPadding="7" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" BackColor="White" BorderColor="#CCCCCC" BorderWidth="1px" AllowSorting="True">
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
谢谢。
最佳答案
在您的 GridView 上使用模板字段。您需要将 AutoGenerateColumns 设置为 False,然后构建您的列。
<asp:TemplateField> <ItemTemplate> <asp:label id="labelid" text='<%#Eval("Features")%>' runat="server" Width="200px"></asp:label> </ItemTemplate> </asp:TemplateField>
关于css - Gridview Re-size for cell data ASP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24616057/