Solved

C# List<>

Posted on 2012-03-19
8
227 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
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:Slimfinger
Comment Utility
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
Comment Utility
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:Slimfinger
Comment Utility
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
 
LVL 1

Author Comment

by:CipherIS
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Expert Comment

by:Slimfinger
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Figured it Out
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now