Isha Jain
Isha Jain

Reputation: 39

bind dropdownlist according to the header of the gridview

I have a dropdownlist and the gridview and I want to bind the dropdownlist according to the header of the grid view

eg.

If I have a grid view header like

  A     B       C        D   edit    delete

Then the dropdown should have values like

A
B
C
D

Upvotes: 0

Views: 436

Answers (1)

Damith
Damith

Reputation: 63105

something like below

    List<string> list = new List<string>();
    for (int i = 0; i < GridView1.Columns.Count ; i++)
    {
        list.Add(GridView1.Columns[i].HeaderText);
    }
    DropDownList1.DataSource = list;

Upvotes: 2

Related Questions