Asp.net GridView自动生成列和排序

Asp.net GridView自动生成列和排序,asp.net,vb.net,gridview,sorting,Asp.net,Vb.net,Gridview,Sorting,关于VB.NET中GridView排序的问题: 我有一个带有AutoGenerateColumns=True的GridView <asp:GridView ID="GridView1" FooterStyle-BackColor="Aquamarine" AutoGenerateColumns="true" AllowSorting="true" OnSorting="Gridview1_Sorting" AllowPaging="True" PageSize="12" OnRow

关于VB.NET中GridView排序的问题:

我有一个带有
AutoGenerateColumns=True的GridView

<asp:GridView ID="GridView1" FooterStyle-BackColor="Aquamarine"
  AutoGenerateColumns="true" AllowSorting="true" OnSorting="Gridview1_Sorting"
  AllowPaging="True" PageSize="12" OnRowCreated="GridView1_RowCreated"
  RowStyle-Wrap="true" runat="server" Width="100%" >
    <HeaderStyle BackColor="#E0E0E0" ForeColor="#000000"/>
    <FooterStyle BackColor="Aquamarine" />
        <emptydatarowstyle backcolor="#CBE0FD" forecolor="#0000FF"/>
</asp:GridView>
设置HeaderRow文本时,我无法再单击标题进行排序(标题也不再带下划线)。 如何更正此错误?

请参见


您需要在控件集中找到链接按钮,然后更新链接文本。

您可以通过在网格使用的sql查询中为列添加别名来更改列标题:

Select ColumnA as [Whatever], ColumnB as [Name It This] From Table .... 

非常好。需要将“”替换为等。HTMLencode链接按钮文本Dim tblThisCell为e.Row中每个tblThisCell的表格单元格。单元格尝试Dim lnkButton As LinkButton=tblThisCell。控件(0)选择大小写lnkButton。文本大小写为“DOC_Bezeichung”lnkButton.Text=“Dokument”End选择Catch ex作为异常MyDebug.MsgBox(ex.Message)End Try Next End如果也很好,会给我带来问题,因为使用此方法我必须更改查询。
Select ColumnA as [Whatever], ColumnB as [Name It This] From Table ....