I want to display Product information from the Product_Id on product click.
I m trying to show details of product in Repeater control but unable to fetch data from database, even not an image. I want to show data according to id on detail page.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div style="height:300px; width:600px; border-style:solid; border-width:1px;" >
<div style="height:300px; width:200px; float:left; border-style:solid; border-width:1px;" >
<img src='../<%#Eval("image")%>' height="300" width="200"
</div>
<div style="height:300px; width:395px; float:left; border-style:solid; border-width:1px;" >
Name=<%#Eval("name") %><br />
Description=<%#Eval("description") %>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
code
public partial class detail : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ToString());
int id;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString[id] == null)
{
id = Convert.ToInt32(Request.QueryString["id"].ToString());
}
con.Open();
SqlCommand cmd = new SqlCommand("select * from Admin_Product_Update", con);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter sdr = new SqlDataAdapter(cmd);
sdr.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
con.Close();
}
}
1 Kolagen This is best cricket ball ever used 1999 ~/Product_Images_Update/ball 5.jpg
2 Sg test REnglish Willow Bat 2999 ~/Product_Images_Update/bat 8.jpg
2 Ss custom best bat ever made by ss 4955 ~/Product_Images_Update/bat 1.jpg
2 kookaburra bat Highly suitable for cricketers 29999 ~/Product_Images_Update/bat 4.jpg
NULL NULL NULL NULL NULL