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 7819161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:50:13+00:00 2026-06-02T06:50:13+00:00

Im pretty new to the object oriented realm and Im a little puzzled how

  • 0

Im pretty new to the object oriented realm and Im a little puzzled how to declare a gridview control and set it to an instance of an object. Im having trouble with the null reference exception error and thats because it is not referenced correctly.

 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
       var MyLabel = (Label) GridView1.FindControl("lblTest");

       cmd.Parameters.Add("@X", SqlDbType.Char).Value = MyLabel.Text;
}

lblTest is the name of the label control in the gridview. But I need to declare this globally and I am not too sure how. If someone could point me to the right direction and help me with the syntax it would be greatly appreciated!

  • 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-06-02T06:50:15+00:00Added an answer on June 2, 2026 at 6:50 am

    If you do have gridview control on the aspx page with lblTest in it then you need to find control on a particular row. In GridView1_RowUpdating do:

    GridViewRow row = GridView1.Rows[e.RowIndex];
    var MyLabel = row.FindControl("lblTest");
    

    Here you could do:

    Label MyLabel = row.FindControl("lblTest");
    

    Var is used for implicit typed variable. You can find this link interesting for var

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am pretty new to object oriented programing, and I am trying to
I'm relatively new to Object Oriented Programming. I pretty much understand the concepts, but
I am pretty new to using object/classes in PHP and I am curious about
I'm pretty new to javascript and am wondering about quoting the keys in object
I'm pretty new to rails, and I have some trouble getting the philosophy and
Of the object-oriented languages I know, pretty much all but C++ and Objective-C compile
I'm pretty new to objective c, and having some basic problems. I wrote a
Im pretty new to Java Web Services, but I cant find a good explanation
I pretty new to Objective-C (and C itself) and need to consume a NSData
I'm pretty new to WPF however i've got a solid understanding of WindowsForms. When

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.