Accessing GridView Boundfields

I have a gridview with a number of BoundFields in it.

In the C# Codebehind i'm trying to evaluate one of the columns like the attached but it's not getting anything even though the GridView is populated.
protected void OrdersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string TheOrderID = e.Row.Cells[0].Text.ToString();
            Response.Write(TheOrderID);
        }
     }

Open in new window

andrewmilnerAsked:
Who is Participating?
 
chuckdscConnect With a Mentor Commented:
check this , mis-typed the earlier post

onrowdatabound="GridView1_RowDataBound"
0
 
chuckdscCommented:
andrewmilner

is the boundfiled you are trying to access visible?
0
 
andrewmilnerAuthor Commented:
Yes it is.
0
 
chuckdscCommented:
andrewmilner:

can you check if the gridview control has the following property setup correctly, pointing it to the correct event handler

onselectedindexchanged="GridView1_SelectedIndexChanged"

Chuck
0
 
andrewmilnerAuthor Commented:
That was it.  Thank you!
I was using OnRowSelecting.
0
All Courses

From novice to tech pro — start learning today.