Click here to Skip to main content
14,270,278 members
Rate this:
Please Sign up or sign in to vote.
Hi,
I have two divs in my view div1 and div 2
div2 is invisible by default
div1 has one link, if user click on that link then div2 should be visible, until then its fine
div1 has a dropdown
@Html.DropDownListFor(x => x.SelectedRegId, new SelectList(Model.regions, "RegionId", "Name", Model.SelectedRegId), new { @class = "select1", style = "width: 150px;" })


and div2 have another dropdown

@Html.DropDownListFor(x => x. @Html.DropDownListFor(x => x.SelectedRegIdRpt, new SelectList(Model.regions, "RegionId", "Name", Model.SelectedRegId), new { @class = "select1", style = "width: 150px;" }), new SelectList(Model.regions, "RegionId", "Name", Model.SelectedRegId), new { @class = "select1", style = "width: 150px;" })


Both dropdowns are being populated by Datasource and value-name field coming for them are
1-Central
2-West
3-East

by default both dropdownlist's selected values are Central (First one from database)
I want to set dropdown SelectedRegIdRpt's selected values to be value that is selected in SelectedRegId in div1 before click on link to make div2 visible, I googled a alot but no result, I found this

public SelectList(
    IEnumerable items,
    string dataValueField,
    string dataTextField,
    Object selectedValue
)


but it works on static data, my data is coming from database as I mentioned, any way to accomplish this.
Thanks
Posted
Updated 12-Oct-17 2:24am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100