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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:15:55+00:00 2026-06-02T02:15:55+00:00

At the moment I have a Silverlight application in Windows Phone which uses the

  • 0

At the moment I have a Silverlight application in Windows Phone which uses the local database. Basically a listBox is generated to show the current list of stored ‘clients’, which works fine. Now I would like to be able to let the user Edit one of the client’s details. For this, I created a new page which is loaded whenever a user clicks on a button from the main page. The event is the following:

public ClientItem selectedClient;

public void Edit_Click(object sender, EventArgs e)
    {
        if (clientItemsListBox.SelectedItem != null)
        {
            selectedClient = clientItemsListBox.SelectedItem as ClientItem;

            NavigationService.Navigate(new Uri("/EditClient.xaml", UriKind.Relative));
        }
    }

The above simply checks which client is selected, stores it as selectedClient and navigates to the EditClient page.

In the EditClient class I have the following method:

 public void saveButton_Click(object sender, RoutedEventArgs e)
    {
        //Get the client that is selected

        ClientItem clientForDelete = mainPage.selectedClient;
        mainPage.ClientItems.Remove(clientForDelete);
        mainPage.clientDB.ClientItems.DeleteOnSubmit(clientForDelete);

        // Create a new client based on the text boxes
        ClientItem newClient = new ClientItem { ClientName = newClientNameTextBox.Text, ClientSurname = newClientSurnameTextBox.Text, ClientCompany = newClientCompanyTextBox.Text, ClientPhone = int.Parse(newClientPhoneTextBox.Text) };

        // Add new client to the database
        mainPage.clientDB.ClientItems.InsertOnSubmit(newClient);

        // Sava database changes
        mainPage.clientDB.SubmitChanges();

        // Go to main screen
        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
    }

When I run this code I get a nullReferenceException when it tries to execute:

mainPage.ClientItems.Remove(clientForDelete);

This is because the selectedClient is null. How can I get the object from the other class without it being null? Because I do not want to delete the item from the main class just in case the user decides to cancel the operation. Also I want to show the details of that client when the page is loaded, which I know how to do if I manage to get the object :). thanks

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

    You can pass the client to the other page as query parameter:

       NavigationService.Navigate(
          new Uri("/MainPage.xaml?client="+clientId, UriKind.Relative));
    

    Then in your MainPage OnNavigatedTo() retrieve the client:

       if (this.NavigationContext.QueryString.ContainsKey("client"))
              client = this.NavigationContext.QueryString["client"]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment i have a stylesheet switcher which uses javascript to to load
I have a Silverlight application that uses resource files to be able to change
At the moment I have a database field which stores passwords like this: TeacherPassword
At the moment I have a slider and an small input text box which
At the moment I have a jQuery do a POST to a Controller which
At the moment I have the following code which works fine. label = new
At the moment I have about 2000 trades which are priced using excel. I
At the moment I'm developing a web based application using Silverlight 3.0. For the
I have a silverlight library which I have added a wcf service reference. Call
at the moment I have a small application and need to take information from

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.