asp.net gridview template column
<p>In my asp.net gridview, I am placing a template column which displays an image.</p>

<p>Inside the template column I added an image control, and it successfully displaying the images from the database. I am also using paging.</p>

<p>Paging also happening but when I do paging images are not coming in the gridview in proper order for example first three pages it diplays suppose a.jpg, b.jpg,c.jpg and when I click on page number it repeats the same picture instead of remaining pictures, i am using <code>if(!ispostback)</code> in the load event also. please help me out.</p>

<p>my code in page load event is:</p>

<p>da = new SqlDataAdapter("select * from t1", con);
        ds = new DataSet();
        da.Fill(ds);
        path = Server.MapPath(@"~\images");
        if (!IsPostBack)
        {
            GridView1.DataSource = ds;
        GridView1.DataBind();</p>

<pre><code>    ASCIIEncoding asc = new ASCIIEncoding();
    int j = GridView1.Rows.Count;

    for (int i = 0; i &lt; j; i++)
    {

        GridViewRow r=GridView1.Rows[i];
        b = (byte[])ds.Tables[0].Rows[i]["photo"];
        string name = asc.GetString(b);
        Image img = (Image)r.FindControl("Image1");
        img.ImageUrl = path + @"\" + name;

    }
    }
</code></pre>

<p>and my code in paging event is</p>

<p>GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = ds;
        GridView1.DataBind();
        ASCIIEncoding asc = new ASCIIEncoding();
int j = GridView1.Rows.Count;</p>

<pre><code>    for (int i = 0; i &lt; j; i++)
    {

        GridViewRow r=GridView1.Rows[i];
        b = (byte[])ds.Tables[0].Rows[i]["photo"];
        string name = asc.GetString(b);
        Image img = (Image)r.FindControl("Image1");
        img.ImageUrl = path + @"\" + name;

    }
</code></pre>

<p>thank in advance
sangita</p>
