views:

26

answers:

2

I am having 2 web formsand will have a drop down list on those web forms. If i select a value from drop down and click on ok i will get tranfer to next page. In that page i will have a drop down with the same values in the previous form . What i need is i would like to disable the selected value in the previos form and would like to display the remaining normal

A: 

I dont know your exact scenario but i would suggest that you look at whether you can maybe achieve your needs using a single form instead of two.

If that is not an option :-

  1. If you are POSTING the form on click of OK, you can retrieve the value of the original page using PreviousPage. Refer eg below.

I am not quite sure what you mean by "disable the selected value in the previos form and would like to display the remaining normal" but once you retrieve this value, then you can manipulate the data in your current page any way you want.

DropDownList oldValue = (DropDownList)PreviousPage.FindControl("DropDownOldValue");

oldValue.SelectedValue - should then give you the value selected on the previous page
InSane
We can find the control but how can we find the selected value as per you said
Dorababu
Doesnt dropDownControl.SelectedValue give you the value?
InSane
But using find control we can find the control but how can we get that value
Dorababu
Ok now how to disable that previous selected value in the current form
Dorababu
A: 

Got the answer

    DropDownList oldvalue = (DropDownList)PreviousPage.FindControl("DropDownList1");
    string str = oldvalue.SelectedValue.ToString();

    ListItem i = DropDownList1.Items.FindByValue(str);
    i.Attributes.Add("style", "color:gray;");
    i.Attributes.Add("disabled", "true");
Dorababu