473,387 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Retrieve SortedList from Class (App_Code)

Hello,

I have a method in my codefile that builds a sorted list (see CodeFile). I
am trying to create a class that does the same thing (see App_Code).

CodeFile
===================================
public void PostSearch(string HRID)
{
SortedList PostSearchList = new SortedList();

try
{

....

foreach(PropertyValueCollection props in item.Properties)
{
PostSearchList.Add(props.PropertyName.ToString(),
props[0].ToString());
}

//Set Values
this.hdnLDAPEmail.Value = PostSearchList["mail"].ToString().Trim();
this.hdnLDAPTelephone.Value =
PostSearchList["telephonenumber"].ToString().Trim();
} // end try

catch(Exception ex)
{
string strNoLDAP = "<br /><br />Please submit a <a
href='members.aspx'>New HRID</a>.<br />";
}
}

App_Code
===================================
public SortedList PostSearchHRID(string HRID)
{
SortedList PostSearchList = new SortedList();

try
{
foreach(PropertyValueCollection props in item.Properties)
{
PostSearchList.Add(props.PropertyName.ToString(),
props[0].ToString());
}

return PostSearchList;

} // end try

catch(Exception ex)
{
strNoLDAP += "<br /><br /><span class=BlkB>LDAP Error</span><br />" +
ex.Message.ToString();

PostSearchList.Add("Catch Exception", strNoLDAP);

return PostSearchList;
}
} // end class

My question is how do you return a sorted list that's in the class?

Code calling the class
======================
protected void Page_Load(object sender, EventArgs e)
{
string LDAPName = this.AppCodePostSearch("cn").ToString();
}

protected SortedList AppCodePostSearch()
{
PostSearch PostSearchHelper = new PostSearch();
return PostSearchHelper.PostSearchHRID(this.txtHRID.Text) ;
}
When I try to reference the class, I get the following:

?LDAPName = "System.Collections.SortedList"

The actual value should be ?LDAPName = "Last Name, First Name"
Any help would be appreciated. Thanks, sck10
Sep 24 '06 #1
4 1526
Hi sck10,

Do you have another implementation of AppCodePostSearch() which takes one
string parameter? I think your code calling the AppCodePostSearch() should
be:

protected void Page_Load(object sender, EventArgs e)
{
string LDAPName = this.AppCodePostSearch()["cn"].ToString();
}

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 25 '06 #2
Thank you very much Walter,

That answered my second question of how to send a value to the method
"AppCodePostSearch(this.HRID.Text)":

string LDAPName = this.AppCodePostSearch(this.HRID.Text)["cn"].ToString();

Cheers...

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:PS**************@TK2MSFTNGXA01.phx.gbl...
Hi sck10,

Do you have another implementation of AppCodePostSearch() which takes one
string parameter? I think your code calling the AppCodePostSearch() should
be:

protected void Page_Load(object sender, EventArgs e)
{
string LDAPName = this.AppCodePostSearch()["cn"].ToString();
}

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 25 '06 #3
Hi sck10,

Sorry, I overlooked the first question "how do you return a sorted list
that's in the class?". However, I'm not very clear about what do you mean
of the question. Could you please depict more? Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 26 '06 #4
Hi Walter,

Both my question of 1. how to return a SortedList and how to provide a value
to the method were answered when you showed me the correct syntax.

I originally created the following to call a class in App_Code that I could
supply a parameter value:

Example 1
========================
protected SortedList AppCodePostSearch(string HRID)
{
PostSearch PostSearchHelper = new PostSearch();
return PostSearchHelper.PostSearchHRID(HRID);
}

I couldn't figure out how to send a value to the class so I hard coded the
method:

Example 2
========================
protected SortedList AppCodePostSearch()
{
PostSearch PostSearchHelper = new PostSearch();
return PostSearchHelper.PostSearchHRID(this.txtHRID.Text) ;
}
The reason I couldn't figure out how to send the parameter value (example 1)
instead of hard coding the value (example 2) was because my of my syntax:

What I originally had was wrong:
string LDAPName = this.AppCodePostSearch["cn"].ToString();

which should have been:
string LDAPName = this.AppCodePostSearch().["cn"].ToString();

which leads to:
string LDAPName = this.AppCodePostSearch(this.HRID.Text)["cn"].ToString();

As always, thanks for all your help...

sck10


"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:l0**************@TK2MSFTNGXA01.phx.gbl...
Hi sck10,

Sorry, I overlooked the first question "how do you return a sorted list
that's in the class?". However, I'm not very clear about what do you mean
of the question. Could you please depict more? Thanks.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gerrod | last post by:
Hi - Does anyone know a way to created a SortedList (in the System.Collections namespace) that will sort on VALUES instead of KEYS... ? The scenario is this - I have a SortedList containing...
6
by: Jose Jarabo | last post by:
Hello, thanks in advance for any and all replies. I am not sure how to categorize this, either a bug or something else but here is my problem. I am testing with 2 elements on a sorted list. If...
5
by: Brett Romero | last post by:
I'd like to type a SortedList as very generic on class instantiation: SortedList<T, T> _sl; Then in two particular methods of the class that is called first(of which only one or the other is...
2
by: Prez | last post by:
I started writing .net code yesterday and I am grasping it well enough. I have a few questions about SortedLists. I am using managed C++ if that makes any difference. Of the examples I...
4
by: SHEBERT | last post by:
Here is an example of a SortedList that works as a datasource to the ComboBox and a generic SortedList<that does not works as a datasource to the ComboBox. Why? If I use List and generic List<>,...
4
by: semedao | last post by:
Hi, I want to implement list of key-values that can be sort by 2 ways. let's say that in the first step I wanted to make SortList based on Key = int index that cannot change and Value is another...
1
by: raylopez99 | last post by:
I seem to get name collision between the Generic collection SortedList and C++.NET Framework collection SortedList. How to resolve? Here are the libraries that seem to clash:...
1
by: xzzy | last post by:
1 - namespace myNS 2 - {internal class clsClass 3 - { 4 - SortedList mySL1 = new SortedList(); 5 - SortedList mySL = SortedList.Synchronized( mySL1 );
8
by: shapper | last post by:
Hello, I am working with VS 2008 and created a Web Application Project. I added a class but whatever I do the class is not visible to my aspx pages or anywhere else. I then changed the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.