3
Reply

how to show image in image control from gridview in another

Garishma Gupta

Garishma Gupta

Mar 28 2014 6:23 AM
999
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(); 
 

Answers (3)