C# 如何从数据库中取出gridview的headertext?
下面是一个场景。我需要从数据库中提取gridview的headertext。我将给出我想要从数据库中得到的给定字段的列名,因为我不需要显示从数据库到gridview的所有列。这是我到目前为止得到的。这是aspx代码C# 如何从数据库中取出gridview的headertext?,c#,asp.net,gridview,.net-2.0,headertext,C#,Asp.net,Gridview,.net 2.0,Headertext,下面是一个场景。我需要从数据库中提取gridview的headertext。我将给出我想要从数据库中得到的给定字段的列名,因为我不需要显示从数据库到gridview的所有列。这是我到目前为止得到的。这是aspx代码 <asp:GridView ID="gvCustProfile" runat="server" AllowPaging="True" DataKeyNames="custname" AutoGenerateColumns="False" BorderS
<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">
有什么方法可以从数据库中指定我想要的列名并获取它的文本值,因为我根本不想硬编码它。我的代码将传递类似“ACTIVE_YN”的值,并将在字典(数据库中)中进行匹配,然后返回对我传递的值的用户友好描述
gvCustProfile.Columns["ACTIVE_YN"].HeaderText = GetColNameFromDictionary(inputColName, profileTable);