Grid View

  • Thread starter Thread starter Seema Multani
  • Start date Start date
S

Seema Multani

I have a Grid view. It is invisible to my form. It has 2 columns. I want
to grab the values of Filename column where Item(column) = 10000. e.g it
should return me an array of filename
column values for 10000.

Item
Filename

10000
Tif file

10000
Pdf file

100200
Pdf file

99999
Text file

10000
Excel file



Thanks
 
Hi Seema,

you can try something like this -

// Declare a StringBuilder variable to store the filenames
System.Text.StringBuilder sb = new System.Text.StringBuilder();

Then in the GridViews's RowDataBound event -

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "10000")
{
sb.Append(e.Row.Cells[1].Text);
sb.Append("~");
ViewState["FileNames"] = sb.ToString();
}
}
}

So the ViewState["FileNames"] should contain list of all files separated by
"~".

HTH.
 
Back
Top