1

So here is the scenario. I need to pull out headertext from database for my gridview. I am going to give the column name of the given fields that I want from the database becuase I dont need to show all the columns from database to gridview. Here is what I have got so far. Here is aspx code.

 <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">

Here is what I got in CS file.

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

Is there any way where I can specify the column name I want from database and get the text value of it since I dont want to hardcode it at all. My code will pass the value like "ACTIVE_YN" and is going to match up in a dictionary (which is in database) and return me a user friendly description to the value I pass.

asheeshr
  • 4,088
  • 6
  • 31
  • 50
HereToLearn_
  • 1,150
  • 4
  • 26
  • 47

0 Answers0