1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] How to get the Headers/Column Name of gridview table binded with SqlDataSource

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 9, 2021.

  1. Stack

    Stack Membro Participativo

    I want to extract the columns names of gridview and bind those columns names with a drop down to make a filter template. I'm facing little challenge to get the columns names from gridview on page load event. Below is the code what i am trying with error.

    and "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

    Response.Write(GridView1.Rows[0].Cells[0].Text.ToString());
    Response.Write(GridView1.Rows[0].Cells[1].Text.ToString());
    Response.Write(GridView1.Rows[0].Cells[2].Text.ToString());
    Response.Write(GridView1.Rows[0].Cells[3].Text.ToString());


    Above code is not working, if it works i can add this in foreach loop for each column

    Note : There is some hidden (visible=false) fields also in gridview

    Continue reading...

Compartilhe esta Página