Restricted Dropdownlist selection in ASP.net webform

Rattlesnake

Freshman
Joined
Dec 23, 2003
Messages
47
Hi,
I have a ASP.net application that has a webform that contains a Dropdownlist (webcontrol). Lets say the dropdownlist has the values 1,2,3,4 (These values are retrieved from a Database. )
I have 2 types of users accessing the application - "Normal Users" and "Admins". Both can be accessing and updating same
records.
What I want is that , in the dropdownlist the "Normal Users" should only be able to select 1 or 2 from the dropdownlist.

Whereas the Admins should be able to select any of the values.

But the "Normal Users" should be able to SEE 3 or 4 , if it was previously selected by an Admin user.

Does anyone know how I can implement this?

Thanks
 
Rattlesnake said:
Hi,
I have a ASP.net application that has a webform that contains a Dropdownlist (webcontrol). Lets say the dropdownlist has the values 1,2,3,4 (These values are retrieved from a Database. )
I have 2 types of users accessing the application - "Normal Users" and "Admins". Both can be accessing and updating same
records.
What I want is that , in the dropdownlist the "Normal Users" should only be able to select 1 or 2 from the dropdownlist.

Whereas the Admins should be able to select any of the values.

But the "Normal Users" should be able to SEE 3 or 4 , if it was previously selected by an Admin user.

Does anyone know how I can implement this?

Thanks

If it's set to 3 or 4, can the normal user change it?
 
you could just disable the control...

or

I use this function to remove all values, but the selected value. Then you can enter in the item for the user, but they won't be able to change it. I use this, because I don't like the way a disabled control is so had to read (because it's greyed out)

Code:
'This function is designed to replace the .enabled function, by removing all but the selected item from the list. 
    'The reasoning behind this function is to make the combo look better, and not have the text grayed out.
    Friend Function DisableComboBox(ByVal objCombo As System.Web.UI.WebControls.DropDownList) As Boolean

        Dim objItem As ListItem

        objItem = objCombo.SelectedItem
        objCombo.Items.Clear()
        objCombo.Items.Add(objItem)

    End Function
 
Back
Top