I'm trying to extend a .NET membership registration control with some custom member type properties. One of these properties is a drop-down list. I've read a post about using Prevalues.GetPrevalues but am struggling with the syntax to bind this to the dropdownlist control in my form.
var TypeOfUserOptions = PreValues.GetPreValues(5611); for (int i = 0; i < TypeOfUserOptions.Count; i++){ TypeOfUserDropDown.Items.Add(new ListItem()); } }
It feels like I'm getting close, but I just don't know how to get the values to populate the drop-down. Am I on the right lines here?
Sorry to bump this folks, but my .NET skills aren't the best, and I'm picking this up again after struggling with it for way too long! Anyone have any pointers at all?
Thanks LOADS for this. I'd been through something very much like it (and a million other variations) on my way to my code above, but I'd always got errors on compilation (usually regarding 'SortedList' requiring two parameters). Since you suggested this again I looked a lot harder into the errors this time and found the root of my problems: I was including the 'using System.Collections.Generic;' namespace rather than 'using System.Collections;'. This has sorted it.
Get custom dropdown list options programatically
Hi,
I'm trying to extend a .NET membership registration control with some custom member type properties. One of these properties is a drop-down list. I've read a post about using Prevalues.GetPrevalues but am struggling with the syntax to bind this to the dropdownlist control in my form.
Can anyone point me in the right direction here?
Thanks.
Okay, here's where I'm at:
It feels like I'm getting close, but I just don't know how to get the values to populate the drop-down. Am I on the right lines here?
Sorry to bump this folks, but my .NET skills aren't the best, and I'm picking this up again after struggling with it for way too long! Anyone have any pointers at all?
PreValues.GetPrevalues returns a SortedList, so you'd have to iterate those using a enumerator. Code snippet should get you started:
Hope this helps.
Regards,
/Dirk
Hi Dirk,
Thanks LOADS for this. I'd been through something very much like it (and a million other variations) on my way to my code above, but I'd always got errors on compilation (usually regarding 'SortedList' requiring two parameters). Since you suggested this again I looked a lot harder into the errors this time and found the root of my problems: I was including the 'using System.Collections.Generic;' namespace rather than 'using System.Collections;'. This has sorted it.
I believe the phrase is H5YR! :)
is working on a reply...