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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:25:06+00:00 2026-05-20T23:25:06+00:00

I am having a problem that I just can’t seem to figure out. The

  • 0

I am having a problem that I just can’t seem to figure out.

The sprint item that I am working on requires me to place an asp.net button in the item template for each item. This button is displayed only if a specific criteria is met. This is working fine, using a ItemDataBound delegate to determine if said button should be shown. Also, in the item template, there is an edit button, which has been in play for some time. Many times, users click the edit button and then click, in the edit template, a button called ‘Save and Close’. This sets the Complete flag in the DB to true. To simplify this process, users want to, in the item template, be able to click save instead of edit that immediately does the same thing as ‘Save and Close’ button when an item is being edited.

The save and close button in the edit template has a command name of ‘Update’ and a command argument of ‘Close’. In the ItemCommand delegate method, I find a checkbox control which is bound to a property on my linq object and I set the checkbox.Checked to true.

I’m currently trying to determine what the best approach would be. At the moment, I have a button in my item template with a CommandName of ‘Update’ and a CommandArgument of ‘CloseReadOnly’. Then, in my ItemCommand delegate method I do the following:

protected void ActivityListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    if (e.CommandName == "Update" && e.CommandArgument == "Close")
    {
        ListViewDataItem dataItem = (ListViewDataItem)e.Item;
        CheckBox completedCheckBox = (CheckBox)dataItem.FindControl("CompletedCheckBox");
        completedCheckBox.Checked = true;
    }

    // new code
    if (e.CommandName == "Update" && e.CommandArgument == "CloseReadOnly")
    {
        ActivityListView.EditIndex = ((ListViewDataItem)e.Item).DataItemIndex;
        // If I put this into play here, I get an exception. A NullReferenceException to be precise.
        //ListViewDataItem dataItem = (ListViewDataItem)e.Item;
        //CheckBox completedCheckBox = (CheckBox)dataItem.FindControl("CompletedCheckBox");
        //completedCheckBox.Checked = true;
    }
}

When I do this, I debug and add a watch of ActivityListView.EditItem, and I get an item that seems to have transitioned to edit mode.

I also have an ItemUpdating delegate method declared that is normally used when a user clicks the edit button in the item template. This delegate method does a few things such as finding a specific control and updating the NewValues collection in the arguments parameter.

ex:

protected void ActivityListView_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
    DropDownList assignedTo = (DropDownList)ActivityListView.Items[e.ItemIndex].FindControl("somecontrol");
    e.NewValues["AssignedTo"] = Convert.ToInt32(assignedTo.SelectedValue);
}

Well, the problem is, FindControl returns null and obviously when trying to convert to int from an object that is null will throw an exception.

So perhaps I’m not in edit mode because if I were, those FindControl’s would work.

Any one have any ideas?

  • 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-20T23:25:06+00:00Added an answer on May 20, 2026 at 11:25 pm

    Hard to debug without all of the code and your code seems right, but here are some guesses.

    Check no rebinding of the listview happens before you get to that event.
    The “Update” command is used to invoke some built in functionality, maybe using that argument is somehow messing up with your functionality. See details of the command names here

    Another way around could be to update your data directly (not changing the controls value) and then rebind your list to display your changes.

    Hope any of these ideas work for you.

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

Sidebar

Related Questions

I have a little newbie problem that I cannot figure out, I am having
I'm having a problem with encoding from a wordpress feed that I just can't
I've been having this problem that I just can't wrap my mind around. I
I am still new to asp.net and I'm having a problem that I just
I'm having a problem with my Seam code and I can't seem to figure
I am having a problem that just started happening in OS 3.1. I have
HI Guys, Here I am having problem that How can I post an image
I'm having a problem and believe something simple, just can't get a grip on
i having problem understanding what is wrong with my inheritance. I just can not
I am having problem that when i am trying to submit the form by

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.