重点是我在项目中使用了GridView
。
我已使用GridView
,SQLConn
和SQlDataAdapter
DataSet
GridView1.DataSource=ds;
GridView1.DataBind();
关键是输出显示了对最终用户不友好的表的列名。
如何更改?
答案 0 :(得分:5)
使用您自己的GridView列,可以分配gridview的Header文本。转到GridView的属性 - >列 - >添加列并将DataBound设置为DB列名称和标题文本属性。
并且不要忘记将GridGe的AutoGeneratedColumns属性设置为false
答案 1 :(得分:0)
您可以按顺序位置更改列名称 - 尽管如果列重新排序,这不是一种强大的方法:
grd.HeaderRow.Cells(iCount).Text = "my column name"
标题单元格中有一个名为AccessibleHeaderText的 它指定用于页面自动化,所以: 会非常强大。 当然你可以通过列 HTH <asp:TemplateField HeaderText="Default Name" AccessibleHeaderText="MY_FIXED_KEY_VALUE">
<ItemTemplate>
<asp:Label ID="CustRef" runat="server" Text='<%# Bind("MyField") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
For iCount = 0 To grd.HeaderRow.Cells.Count - 1
Dim oCol As DataControlField = grd.Columns(iCount)
If String.Compare(oCol.AccessibleHeaderText, "MY_FIXED_KEY_VALUE", True) = 0 Then
grd.HeaderRow.Cells(iCount).Text = "my column name"
Exit For
End If
Next