locked
How to get image in Image Box from saved path on Dropdownlist selected index changed event in c# asp.net? RRS feed

  • Question

  • Hello,

    How to get image in Image Box from saved path on Dropdownlist selected index changed event in c# asp.net?
    I am using this code for display image in image box on Dropdownlist selected index changed:-
    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();

    if (sdr.Read())
    {
     
    ImgLogoSponsor.ImageUrl = Server.MapPath("~/Templates/") + sdr[0].ToString();
    LblAllotedCards.Text = "You have " + sdr[10].ToString() + " free/sponsored cards";
    }
    sdr.Close();
    con.Close();
    }
     
    when I am debugging so, Image path show in ImgLogoSponsor.ImageUrl (Image Url) but Image it's not showing in image box on dropdownlist selected index changed event, in c# asp.net.
     
    Please help me.
     
    Thanks in Advance.
     
    Ankit Agarwal
    Web Developer

    Wednesday, February 5, 2014 7:06 AM

Answers