In my project i have a RecipeDisplay.aspx and RecipList.aspx page.
In RecipeList.aspx page i have a gridview which shows my data from database.
My RecipeTable consists of (Name, Type, Image, Recipe).
When i click on the name of the Recipe i am redirected to RecipeDisplay.aspx (containing a label, image control and textbox). The label is binded to the name of the recipe and in textbox i can read the complete recipe.
The problem i am facing is in image.
I can only see broken image logo in image control.
Please help me of how should i see image traversing through my gridview.
Following is the line of code at RecipeDisplay.aspx.cs:
SqlCommand cmd = new SqlCommand("select * from RecipeTable where Name='" + name + "'", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Label1.Text = name;
TextBox1.Text = dt.Rows[0][4].ToString();
}
con.Close();

Garishma GPosted Mar 29, 2014, 2:33 PM
The code is:
String name = Request.QueryString["Name"];
if (name == "")
{
TextBox1.Text = "Click on the name of the Recipe to get the full Recipe";
}
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TummyFoodyString"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from RecipeTable where Name='" + name + "'", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Label1.Text = name;
TextBox1.Text = dt.Rows[0][4].ToString();
Byte[] bytes = (Byte[])dt.Rows[0]["Image"];
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image2.ImageUrl = "data:image/jpeg;base64," + base64String;
}
con.Close();
Garishma GPosted Mar 28, 2014, 9:35 AM
Please help me with an example or demo code.
Joginder BangerPosted Mar 28, 2014, 7:57 AM
you can do it with the help of javascript or code behind. when you are click the image get a unique id and with this help show to data another page form load event.