我想设置列的文本。 GridView
的正确语法是什么?
Me.gvRefBetweenLineOfBiz.DataSource = query
Me.gvRefBetweenLineOfBiz.DataBind()
EnableControlVisibility(True)
答案 0 :(得分:2)
您可能希望禁用自动生成列,并为要在GridView中显示的每列创建BoundField。每个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>