Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:10:32+00:00 2026-05-15T15:10:32+00:00

What exactly is the e.Row.DataItem return.. MSDN says.. returns An Object that represents the

  • 0

What exactly is the e.Row.DataItem return.. MSDN says.. returns An Object that represents the underlying data object to which the GridViewRow object is bound.

Here is my DataGrid…

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound">
        <Columns>
            <asp:BoundField DataField="PracticeCode" HeaderText="PracticeCode" SortExpression="PracticeCode" />
            <asp:BoundField DataField="AccountNo" HeaderText="AccountNo" SortExpression="AccountNo" />
            <asp:BoundField DataField="PatientName" HeaderText="PatientName" SortExpression="PatientName" />
            <asp:TemplateField HeaderText="Status">
                <ItemTemplate>
                    <asp:Label ID="LblStatus" runat="server"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

And I bind it with my Business Object List < Patient >.. In the row DataBound event, I try this…

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Patient p1 = (Patient)e.Row.DataItem;
        Label lbl = e.Row.FindControl("LblStatus") as Label;

        if (p1 == null)
        {
            throw new Exception("P1 is null");
        }

        if (p1.OpenItems.Count > 0)
        {
            lbl.Text = "Has open Items";
        }
        else
        {
            lbl.Text = "";
        }
    }

I get the exception P1 is null… Why so… What am I missing..

Note : There could be other ways to accomplish this, but I’m looking especially why my p1 is null… and is there any way to get the Patient Object back from GridView after binding.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:10:33+00:00Added an answer on May 15, 2026 at 3:10 pm

    RowDataBound is called for the header and footer also, you need to make sure your currently in an actual DataRow before calling e.Row.DataItem:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {                
           if(e.Row.RowType != DataControlRowType.DataRow)
              return;
    
           Patient p1 = (Patient)e.Row.DataItem;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should do it for you: Intent myIntent = new… May 16, 2026 at 12:10 pm
  • Editorial Team
    Editorial Team added an answer Yes, GetInstance<Database> is a call to a generic method, where… May 16, 2026 at 12:10 pm
  • Editorial Team
    Editorial Team added an answer The problem is not specifically with nil. It's that to_json… May 16, 2026 at 12:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a data set that looks like the following. EMPLID PHONE_TYPE PHONE ------
I'm not exactly new to PHP but I haven't used MySQL that much, so
The code in this event is repeated exactly in two other event handlers. How
I have a query that looks like this: select id , int1 , int2
I'm designing data-oriented application in Silverlight 3 and I'm wondering if is it worth
How can I copy an array that has other associative arrays in it? I
I'm having a rough time figuring out exactly how to do a LINQ query
i have two data tables with the same structure the first one has one
What exactly is the difference between: scala> def foo = 5 foo: Int and
What exactly does the VS project option Register for COM interop actually do? Because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.