如何从数据库中提取gridview的headertext?

时间:2012-12-03 16:58:33

标签: c# asp.net gridview .net-2.0 headertext

所以这是场景。我需要从数据库中为我的gridview提取headertext。我将从数据库中提供我想要的给定字段的列名称,因为我不需要显示从数据库到gridview的所有列。这是我到目前为止所得到的。这是aspx代码。

 <asp:GridView ID="gvCustProfile" runat="server" AllowPaging="True" DataKeyNames="custname" AutoGenerateColumns="False"
            BorderStyle="None" GridLines="Horizontal" HeaderStyle-HorizontalAlign="Left"
            ShowFooter="True" Width="125%"  AllowSorting="True">

这是我在CS文件中得到的内容。

gvCustProfile.Columns["ACTIVE_YN"].HeaderText = GetColNameFromDictionary(inputColName, profileTable); 

有没有办法可以从数据库中指定我想要的列名,并获取它的文本值,因为我根本不想对其进行硬编码。我的代码将传递像“ACTIVE_YN”这样的值,并将在字典中(在数据库中)匹配,并返回一个用户友好的描述到我传递的值。

0 个答案:

没有答案
相关问题