Как установить текст заголовка столбца? - PullRequest
0 голосов
/ 29 ноября 2011

Я хотел бы установить текст столбцов.Каков правильный синтаксис для GridView?

Me.gvRefBetweenLineOfBiz.DataSource = query
Me.gvRefBetweenLineOfBiz.DataBind()
EnableControlVisibility(True)

1 Ответ

2 голосов
/ 29 ноября 2011

Вероятно, вы захотите отключить автоматическое создание ваших столбцов и создать BoundField для каждого столбца, который вы хотите отобразить в GridView.Каждый BoundField имеет свойство HeaderText, которое контролирует текст заголовка столбца.

Из документов:

<asp:gridview id="CustomersGridView" 
    datasourceid="CustomersSqlDataSource" 
    autogeneratecolumns="false"
    autogenerateeditbutton="true"
    allowpaging="true" 
    datakeynames="CustomerID"  
    runat="server">

    <columns>
      <asp:boundfield datafield="CustomerID"
        readonly="true"      
        headertext="Customer ID"/>
      <asp:boundfield datafield="CompanyName"
        convertemptystringtonull="true"
        headertext="Customer Name"/>
      <asp:boundfield datafield="Address"
        convertemptystringtonull="true"
        headertext="Address"/>
      <asp:boundfield datafield="City"
        convertemptystringtonull="true"
        headertext="City"/>
      <asp:boundfield datafield="PostalCode"
        convertemptystringtonull="true"
        headertext="ZIP Code"/>
      <asp:boundfield datafield="Country"
        convertemptystringtonull="true"
        headertext="Country"/>
    </columns>

  </asp:gridview>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...