0

Please Help me to solve my problem .. I want to retrieve my images in gridview which stores in database with image datatype. i am newbie so please help me..

SqlConnection conn;
SqlCommand cmd;
SqlDataAdapter adp;
string str;
string strCon = "Data Source=S-PC;Initial Catalog=SA;Integrated Security=True";
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    conn.Open();
    str = "SELECT imgg from SA_Stock where '"+DropDownList1.SelectedItem.Text+"";
    conn = new SqlConnection(strCon);
    cmd=new SqlCommand(str,conn);
    adp=new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    adp.Fill(ds);
    GridView1.DataSource = ds.Tables["SA_Stock"];
    GridView1.DataBind();
    conn.Close();
}

Thanking you for your help in advance..

0

1 Answer 1

0

Try tto get the reference of image control in onrowdatabound event and load the byte array from sql to control. see link below

How to display image inside web form from Byte Array with C#

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your reply.. But i have to link it with my gridview control dynamically..
From the posted code it gives a feel that GridView1 is defined in the mark up. if so then what are you referring to when saying building dynamically.
Thank you mate for your concern i solved my issue .. and it is ".cs" code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.