Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
dropdownlistfor(model=>model.ddlstatevalue)
for eg ddlstatevalue contains apple,ball,cat
if i select apple then there must be display of pic of aapple
if i select ball then there must be image of ball and so on
how can i do this ?
Posted

 
Share this answer
 
If you want to use simple asp.net code then try the below. before that add the images in your solution. Hope this helps.

XML
<div>
        <asp:DropDownList ID="ddlstateval" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlstateval_SelectedIndexChanged">
            <asp:ListItem Text="Apple" Value="Apple"></asp:ListItem>
            <asp:ListItem Text="Cat" Value="Cat"></asp:ListItem>
            <asp:ListItem Text="Ball" Value="Ball"></asp:ListItem>
        </asp:DropDownList>
    </div>
    <div>
        <asp:Image ID="imgViewSelected" runat="server" ImageUrl="~/Images/Apple.jpg" />
    </div>



code behind

C#
protected void ddlstateval_SelectedIndexChanged(object sender, EventArgs e)
        {
            imgViewSelected.ImageUrl = "~/Images/"+ddlstateval.SelectedValue.ToString() + ".jpg/";
        }
 
Share this answer
 
v2
Comments
sajan064 21-Feb-12 6:29am    
thanks
m not using simple asp.net code
i have binded dropdownlist value from the table from database
beevif 21-Feb-12 6:41am    
thanks for the comments. Hope you already solved.

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