Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

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

0
andrewmilner
Asked:
andrewmilner
  • 3
  • 2
1 Solution
 
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
 
chuckdscCommented:
check this , mis-typed the earlier post

onrowdatabound="GridView1_RowDataBound"
0
 
andrewmilnerAuthor Commented:
That was it.  Thank you!
I was using OnRowSelecting.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now