Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I have hospital1(H1), hospital2(H2) , hospital3(H3) in ddl1 and emergency(E),accounts (A),general (G) in ddl2

I want to go for all combinations H1E,H1A,H1G,H2E,H2A,H2G, H3E,H3A,H3G each item is a
webpage by selecting dropdown controls.

How do i do that?

plz help me.


Thanks,
Kranthi
Posted

The idea goes like this, concatenate the selected values from the 2 dropdownlists to make up the redirected page name:
on button click
string hospital = ddl1.SelectedItem.Value;   // e.g. "H1" 
string type = ddl2.SelectedItem.Value;        // e.g. "E" 
string para = "http://sitename/" + hospital + type;   // e.g. "H1E"
Response.Redirect(para);

Refer: bind data to dropdownlist with c#[^]
 
Share this answer
 
v3
You can directly do that inside the Button Click or something after you select both the DropDowwnLists.
C#
protected void Button Click(object sender, EventArgs e)
{
    RedirectToAPageRelatedToDropDownSelectedValues(ddl1.SelectedValue, dd2.SelectedValue);
    // I assume the DropDown values are same as texts.
}

private void RedirectToAPageRelatedToDropDownSelectedValues(DropDown1SelectedValue, DropDown2SelectedValue)
{
    if(DropDown1SelectedValue.Equals("H1") && DropDown2SelectedValue.Equals("E"))
    {
        // Do whatever you want.
    }
    else if(DropDown1SelectedValue.Equals("H1") && DropDown2SelectedValue.Equals("E"))
    {
        // Do whatever you want.
    }
    // Write for all the combinations.
}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900