Mike Simo

Mike Simo

  • NA
  • 17
  • 11.8k

Show image from table

Jul 2 2014 9:46 PM
Hi
I have top banner in my application which will show an image and i am using "location" session so first page of application allow user to chosse his country and then redirect him to the selected country page. what i am looking for to show each image on the spacific page depending on session. Here is my server code which is not working and the image its not appear  
 
protected void Topbannerimgbtn_Click(object sender, EventArgs e)
{
var location = Convert.ToString(Session["location"]);
using (SqlConnection topbanner = new SqlConnection(sc))
{
topbanner.Open();
SqlDataAdapter DAtopban = new SqlDataAdapter("Select advimg from Adverttop WHERE ([Country] = @Country)", sc);
DataSet DStopban = new DataSet();
DAtopban.SelectCommand.Parameters.AddWithValue("@Country", location);
DAtopban.Fill(DStopban);
bannertoplstviw.DataSource = DStopban.Tables[0];
bannertoplstviw.DataBind();
}
}
 
 
and here is aspx code:
 
<div class="bannertop">
<asp:ListView ID="bannertoplstviw" runat="server">
<ItemTemplate>
<asp:ImageButton ID="Topbannerimgbtn" runat="server" ImageUrl='<%# "/images/AdsImgs/" + Eval("advimg") %>' CausesValidation="false" />
</ItemTemplate>
</asp:ListView>
</div>
 
 
 
 

Answers (3)