Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't add property of Active Directory user to DropDownList

Status
Not open for further replies.

marcasii

Programmer
Aug 27, 2001
109
AU
Hi, I am trying to do this using C#:

Code:
myDropDownList.Items.Add(new ListItem(res.Properties["Name"][0],res.Properties["samaccountname"][0]));

but it is giving an error saying: "The best overloaded method match for 'System.Web.UI.WebControls.ListItem.ListItem(string, string)' has some invalid arguments"

I have also tried:

Code:
string a = res.Properties["Name"][0];

but it says: "cannot convert type object to string"

I retrieved the object type using GetType() and it says it is a System.String!!!

Any ideas why this is not working???
 
I'm not familiar with that construction... with two brackets back-to-back. It looks odd:

res.Properties["Name"][0]

Are you sure that's right?



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting


If this post was helpful, click some ads! My personal site is also advertiser-supported. Hint, hint!
 
Yes. I can do this:

Code:
Response.Write(res.Properties["Name"][0];)
 
what about

string a = res.Properties["Name"][0].ToString();

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Ordinarily yes but the problem I was getting was to do with the "Name" property not existing for some entries. Thanks for the posts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top