Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get column names of grid in asp.net????
plz help me...
thnks in advance...
Posted

Hi
You can column by using

C#
Label1.Text = grdEmpDet.Columns[1].HeaderText;


you can also ron for loop for finding each column name in grid

C#
for (int i = 0; i <= grdEmpDet.Columns.Count; i++)
       {
           Label1.Text = grdEmpDet.Columns[i].HeaderText;
       }


Hope this will help you
 
Share this answer
 
v2
Refer the following code.

C#
string colnames = string.Empty;
           for (int i = 0; i < GridView1.Columns.Count; i++)
              colnames += GridView1.Columns[i].HeaderText;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900