Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 4th, 2008, 08:30 AM
Registered User
 
Join Date: Jul 2008
Location: london, , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get GridView Cell Value Based on GridView Column

Hi,

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.

S


    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)
        {
            j++;
            if (j == FMNResultsGridView.SelectedRow.RowIndex)
            {

                Label1.Text = row.Cells[20].Text;

            }
         }



    }


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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? jameslin288@yahoo.com ASP.NET 2.0 Basics 8 November 19th, 2006 12:12 PM



All times are GMT -4. The time now is 08:32 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.