Get GridView Cell Value Based on GridView Column
I have a GridView which is being generated from dynamic XML. The contents and heading of this table change everytime the web app. is run. The results are being displayed fine and it's all working. What I am after is to be able to pull back the easting and northing cell values of a selected row and store them in a hidden field.
The problem i am having is that the possition of these columns changes therefore whilst the code below works its only going to work for one particular xml doc.
Any suggestions will be greatly received.
protected void FMNGridView_SelectedIndexChanged(object sender, EventArgs e)
var FMNRowSelected = (string)FMNResultsGridView.SelectedDataKey.Value;
// Copy the items in the Rows collection into an array.
GridViewRow rowArray = new GridViewRow[FMNResultsGridView.Rows.Count];
// Iterate though the array and display the value in the specified cell of the row
int j = -1;
foreach (GridViewRow row in rowArray)
if (j == FMNResultsGridView.SelectedRow.RowIndex)
Label1.Text = row.Cells.Text;