[英]How to add a header row to a GridView table in VB.NET?
<asp:GridView ID="MemberTable" runat="server"
AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ID" DataSourceID="AccessDataSource1"
EmptyDataText="There are no data records to display." ForeColor="#333333"
GridLines="None" HorizontalAlign="Center">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Forename" HeaderText="Forename" SortExpression="Forename" />
<asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
<asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" SortExpression="EmailAddress" />
<asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
<asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
<asp:BoundField DataField="UserType" HeaderText="UserType" SortExpression="UserType" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
如何在此表的頂部添加單個單元格標題行? (最好僅使用標簽)
謝謝你的幫助!
GridViews對表格的頁眉和頁腳或單元格沒有足夠的控制權。
但是,您說您想要“單個單元格標題行”,這聽起來像您在尋找標題。 有可能 請參見MSDN GridView.Caption 。
<asp:GridView (...) Caption="Hello Table!" CaptionAlign="Left">
並通過使用一些CSS樣式,可以使標題看起來像表格行。
<style type="text/css">
caption {background-color:#E3EAEB; padding:4px}
</style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.