Visual Studio .NET - How to display image in image box after selecting item in dropdown list in

Asked By sarani raji on 10-Apr-14 01:54 AM
In my project i had give one dropdownlist and two image controls. Am connected dropdownlist with database already two images are saved for every id. My work is after am selecting item in dropdownlist it will show already saved images in this two image controls how to give this pls help and thanks in advance. 
Hemanth Kumar replied to sarani raji on 28-Apr-14 06:22 AM
You can bind the images dynamically from Database

protected void Page_Load(object sender, EventArgs e)


if (!IsPostBack)

ddlSocialIcons.Items.Insert(0, new ListItem("Select Any Icon ", " "));


protected void ddlSocialIcons_SelectedIndexChanged(object sender, EventArgs e)


if (ddlSocialIcons.SelectedItem == null)


switch (ddlSocialIcons.SelectedItem.Value.ToString())


case "1":

imgSocialIcon.ImageUrl = "~/SocialIcons/06-facebook-128.png";


case "2":

imgSocialIcon.ImageUrl = "~/SocialIcons/03-twitter-128.png";


case "3":

imgSocialIcon.ImageUrl = "~/SocialIcons/80-google-plus-128.png";


case "4":

imgSocialIcon.ImageUrl = "~/SocialIcons/47-skype-128.png";



imgSocialIcon.ImageUrl = "~/SocialIcons/noimage.png";




Design form ;

<form id="form1" runat="server">


<asp:DropDownList runat="server" ID="ddlSocialIcons" AutoPostBack="true" OnSelectedIndexChanged="ddlSocialIcons_SelectedIndexChanged">

<asp:ListItem Text="FaceBook" Value="1" />

<asp:ListItem Text="Twitter" Value="2" />

<asp:ListItem Text="Google+" Value="3" />

<asp:ListItem Text="Skype" Value="4" />



<div style="width: 50%; height: 50%">

<asp:Image ID="imgSocialIcon" runat="server" />



sarani raji replied to Hemanth Kumar on 30-Apr-14 05:53 AM
thank u sir but am connect dropdownlist to sql database i dont know how to display images in imagebox already images are saved in database how to retrive after am select this dropdown selected item