Kunle
Kunle

Reputation: 63

all value in gridview

I have a grid view table populated using a stored procedure. The grid view table loads and works fine. The problem I am having is how to get all the values in a particular column.

So far, I can only get the value of the 1 column and cell. I need all the values in that column for each row. Numbers of value varies depending on the parameters user set.

code is in c#. This gets me the first column, first row.

 gridviewID.DataSource = cmd.ExecuteReader();
            gridviewID.DataBind();
            TxBx.Text = gridviewID.Rows[0].Cells[0].Text;

Upvotes: 1

Views: 1894

Answers (1)

Kiran Hegde
Kiran Hegde

Reputation: 3681

You can use for each loop to get all the rows within the grid view.

IList<string> parameters = new List<string>();
foreach (GridViewRow row in AdminSearchGridView.Rows)
{
  parameters.Add(row.Cells[0].Text);
}

Upvotes: 1

Related Questions