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

  • Home
  • SEARCH
  • 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 6733405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:45:53+00:00 2026-05-26T10:45:53+00:00

when i work with selectionchanged event in datagridview. if i click column header it

  • 0

when i work with selectionchanged event in datagridview.
if i click column header it give me that exception:
NullReferenceException was unhandled by user code
Object reference not set to an instance of an object.

it is my code

    private void dgvEvents_SelectionChanged(object sender, EventArgs e)
    {
        //
        //Select By EventID Operation.
        //
        eventID = int.Parse(dgvEvents.Rows[dgvEvents.CurrentRow.Index].Cells["EventID"].Value.ToString());
        EventEntity = EventsMethods.SelectByID(eventID);
        txtEventName.Text = EventEntity.Name;
        cboxEventsCategories.SelectedValue = EventEntity.EventCategoryID;
        dateTimePickerEvent.Text = EventEntity.Date.ToString();
        txtBenefNum.Text = EventEntity.BeneficiariesNumber.ToString();
        txtResultB.Text = EventEntity.ResultBefore.ToString();
        txtResultA.Text = EventEntity.ResultAfter.ToString();
        txtPercentage.Text = EventEntity.Percentage.ToString();
        //
        //Show EventsMembers.
        //
        FillEventsMembersDGV();
    }
  • 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-26T10:45:53+00:00Added an answer on May 26, 2026 at 10:45 am

    one of these is returning a null object…

    dgvEvents.Rows[dgvEvents.CurrentRow.Index].Cells["EventID"].Value.ToSt‌​ring()
    

    could be any one of these:

    dgvEvents
    dgvEvents.CurrentRow
    dgvEvents.Rows[....]
    dgvEvents.Rows[....].Cells
    dgvEvents.Rows[....].Cells["EventID"]
    dgvEvents.Rows[....].Cells["EventID"].Value
    

    best way to find out, would be to break it into steps:

        var curRow= dvgEvents.CurrentRow;
        if ( curRow != null )
             var index = curRow.Index;
    
    // etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

work on asp.net vs 05 C#.Master page header contain the bellow code <script type=text/javascript
ListBox object is binded with BindingList<KeyValuePair<string, string>> On SelectionChanged event I need to get
if i m using following type of code then SelectionChanged Event of WPF comboBox
Work on this small test application to learn threading/locking. I have the following code,
At work, we have multiple branches that we may be working on at any
The handler of the SelectionChanged event of the ComboBox control has the following signature:
I'm just getting started with silverlight. Basically I have a silverlight user control that
In the ComboBox.SelectionChanged event I want to know who changed the ComboBox value, the
Below is the source code for UseTest.java . Why doesn't it work? import javax.swing.*
Work on Asp.Net vs 08. Below is my code <asp:TextBox ID=txtSTART_DATE runat=server></asp:TextBox> <cc1:PopupControlExtender ID=txtSTART_DATE_PopupControlExtender

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.