Click here to Skip to main content
15,904,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

How to retrieve image from database saved path on DropdownList Selected Value Changed using c# asp.net?

I am using code for display in image url but my image is not displaying.
My text is displaying but my image it's not displaying.
My code is:-
C#
protected void DDLCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);
        
        SqlCommand cmd = new SqlCommand("procGetSponsorDetails",con);
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@CityId", SqlDbType.Int).Value = DDLCity.SelectedItem.Value;
        SqlDataReader sdr = cmd.ExecuteReader();
        //cmd.ExecuteReader();
        if (sdr.Read())
        {
            
            ImgLogoSponsor.ImageUrl = Server.MapPath("~/Templates/") + sdr[0].ToString();
            LblAllotedCards.Text = sdr[10].ToString();
        
        }
        sdr.Close();
con.Close();
}
}

DropdownList and Image in Update panel.
please help me.

Thanks in Advance.

Ankit Agarwal
Website Developer
Posted
Updated 2-Feb-14 20:12pm
v3
Comments
Have you debugged and see what is the issue exactly?
Ahmed Bensaid 3-Feb-14 6:17am    
What is the generated HTML of your image ?
[no name] 3-Feb-14 6:23am    
I have a <asp:Image ID="ImgLogoSponsor" runat="server" style="width:150px;height:150px"
ImageUrl=""/>
tag for image display.
Schatak 22-Mar-14 9:19am    
while debugging what you get in "ImgLogoSponsor"? is is blank?

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