Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 4th, 2008, 08:30 AM
Registered User
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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];
        FMNResultsGridView.Rows.CopyTo(rowArray, 0);

        // 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[20].Text;



Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView - cell wrapping - need help snufse ASP.NET 2.0 Basics 0 July 21st, 2008 04:53 PM
Accessing one cell from gridview Aker C# 1 May 22nd, 2008 03:13 PM
Change value in GridView Cell Sheraz Khan ASP.NET 2.0 Professional 2 August 30th, 2007 11:12 AM
How to change the value of one cell in a GridView? [email protected] ASP.NET 2.0 Basics 8 November 19th, 2006 01:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.