Solved

C# List<>

Posted on 2012-03-19
8
228 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
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:Slimfinger
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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 7

Expert Comment

by:Slimfinger
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Runtime Error 2 28
how to read json value 2 29
Run time Error 4 34
How to have a gridview column with multiple items in a column row. 2 11
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

914 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

17 Experts available now in Live!

Get 1:1 Help Now