Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# List<>

Posted on 2012-03-19
8
Medium Priority
?
250 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: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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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 …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

824 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