Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# List<>

Posted on 2012-03-19
8
Medium Priority
?
241 Views
Last Modified: 2012-03-24
I created a WCF App.  I am returning a list.  I am trying to figure out how to return it to a variable on my client page.  I also need to read the values.

Here is the call to the WCF

LogIn.MyAPILogin(this.txtUserName.Text.Trim, this.txtPassword.Text.Trim);

How do I get the values

List<LoginResults> myresults = LogIn.MyAPILogin(this.txtUserName.Text.Trim, this.txtPassword.Text.Trim);

2 boolean values are returned
- MustChangePassword
- IsAdmin
0
Comment
Question by:CipherIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 37739435
Your question is unclear.  Are you saying that "LoginResults" consists of two booleans?  And why would you receive a list of results from a single login?
0
 
LVL 1

Author Comment

by:CipherIS
ID: 37739446
the sproc returns two values.  Because of this I am returning both values in a list which contains the two values.

And yes, LoginResults (as I said) contains two values:  MustChangePassword, IsAdmin.

I did not design the sproc - I have to code to it.  So I must obtain the values to determine what I have to do on the ASP.NET page.
0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 37739496
What you actually said was "2 boolean values are returned".  Looking at your function call, it is evident that it returns a list - NOT two boolean values.  Are you actually getting two different login results, EACH containing two booleans?  It is still unclear.

I have no idea what is going on at your end.  However, it seem that regardless, you probably simply need to iterate the list and get your values:

foreach (LoginResults results in myresults)
{
   // Do something with 'results'
   if (results.bValue1 == true) whatever;
}
0
Amazon Web Services EC2 Cheat Sheet

AWS EC2 is a core part of AWS’s cloud platform, allowing users to spin up virtual machines for a variety of tasks; however, EC2’s offerings can be overwhelming. Learn the basics with our new AWS cheat sheet – this time on EC2!

 
LVL 1

Author Comment

by:CipherIS
ID: 37739574
Ok, lets see if I can explain this clearer.  I have developed this.

LogIn.MyAPILogin(this.txtUserName.Text, this.txtPassword.Text)

The above returns a list containing
-  MustChangePassword
-  IsAdmin

My question is how do I get those values?

The below code is an example

List<LoginResults> myresults

It does not work.
0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 37739618
Didn't you say that LoginResults contains two bools?  Now you are saying the list contains two bools.
0
 
LVL 1

Author Comment

by:CipherIS
ID: 37739628
no - loginresults is nothing - i used that as an example to get my values from WCF.  This is what I have

LogIn.MyAPILogin(this.txtUserName.Text, this.txtPassword.Text)

This returns a list with two values
-  MustChangePassword
-  IsAdmin

How do I get this list on the client side?
0
 
LVL 1

Accepted Solution

by:
CipherIS earned 0 total points
ID: 37739734
I figured it out

foreach (var results in LogIn.MyAPILogin(this.txtUserName.Text, this.txtPassword.Text))
{
     Session["MustBeChanged"] = results.MustChangePassword;
     Session["IsAdmin"] = results.IsAdmin;
}
0
 
LVL 1

Author Closing Comment

by:CipherIS
ID: 37760301
Figured it Out
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question