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

The Archive Base Latest Questions

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

I am trying to create a customer record which would include First Name, Last

  • 0

I am trying to create a customer record which would include First Name, Last Name, SSN and Date of Birth. When a user selects a customer from the combobox (cboCustomer), it calls the SelectedIndexChanged event. I want to use the selected index to get the correct customer record from my XML.

Here is the query I’ve created, but it is empty. Below the query is my XML data source.

    private void cboCustomer_SelectedIndexChanged(object sender, EventArgs e)
    {
        var doc = XElement.Load("Portfolio.xml");
        customerId = cboCustomer.SelectedIndex.ToString();
        if (cboCustomer.SelectedIndex != 0)
        {
            var custRecord =
                from account in doc.Descendants("account")
                let acct = account.Element("acct")
                where (string)account.Element("custid") == customerId
                select new
                {Fname=(string)account.Element("fname"),
                    Lname = (string)account.Element("lname"),
                    Ssn = (string)account.Element("ssn"),
                    Dob = (string)account.Element("dob")
                };
        }
    }
<?xml version="1.0" encoding="utf-8" ?>
<portfolio>
  <account>
    <acct custid="1" fname="Tommy" lname="Hawk" ssn="928-329-1929" dob="4/6/1988"></acct>
    <deposits depid="1000" depdate="1/2/2011" depamount="1350.53"></deposits>
    <deposits depid="1003" depdate="2/3/2011" depamount="1377.81"></deposits>
    <deposits depid="1008" depdate="3/14/2011" depamount="84.00"></deposits>
    <withdrawals wdid="2001" wddate="1/31/2011" wdamount="80.00"></withdrawals>
    <withdrawals wdid="2005" wddate="4/8/2011" wdamount="80.00"></withdrawals>
    <withdrawals wdid="2007" wddate="6/1/2011" wdamount="2600.00"></withdrawals>
  </account>
  <account>
    <acct custid="2" fname="I. P." lname="Nightly" ssn="457-23-4871" dob="6/1/1945"></acct>
    <deposits depid="1004" depdate="2/8/2011" depamount="741.22"></deposits>
    <deposits depid="1005" depdate="2/9/2011" depamount="47.00"></deposits>
    <deposits depid="1009" depdate="3/14/2011" depamount="89.99"></deposits>
    <withdrawals wdid="2003" wddate="3/1/2011" wdamount="55.00"></withdrawals>
    <withdrawals wdid="2004" wddate="3/3/2011" wdamount="28.00"></withdrawals>
    <withdrawals wdid="2006" wddate="4/8/2011" wdamount="450.00"></withdrawals>
  </account>
  <account>
    <acct custid="3" fname="Mary" lname="Echmass" ssn="192-01-2933" dob="8/10/1973"></acct>
    <deposits depid="1002" depdate="1/15/2011" depamount="841.77"></deposits>
    <deposits depid="1006" depdate="2/14/2011" depamount="2170.00"></deposits>
    <deposits depid="1007" depdate="3/10/2011" depamount="21.01"></deposits>
    <withdrawals wdid="2002" wddate="1/16/2011" wdamount="700.00"></withdrawals>
    <withdrawals wdid="2008" wddate="6/3/2011" wdamount="24.00"></withdrawals>
    <withdrawals wdid="2009" wddate="6/30/2100" wdamount="38.46"></withdrawals>
  </account>  
</portfolio>
  • 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:22:38+00:00Added an answer on May 26, 2026 at 10:22 am

    There is no element custid in your XML, but you’re looking for it in your code.

    You probably want

    where acct.Attribute("custid").Value == customerId
    

    And you need to modify your select in a similar way.

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

Sidebar

Related Questions

Hi I'm trying to create a search box to search customer by last name
I'm trying to create an array to display the last 5 products a customer
Trying to create my first iPhone app that would play back audio. When I
I'm trying to create a form that sends the customer's name and email address
I am trying to create a floating ticker for my customer websites which will
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create a user account in a test. But getting a Object reference
I'm trying to create a function that shows a modal dialog which when called
I am trying to add records into two tables below, CREATE TABLE customer (Custno
So, I've been trying to create a record.however I created it successfully but the

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.