adding functionality to an imageButton in a gridview
<p>Hallo there
I have an <code>ImageButton</code> control as part of a <code>GridView</code> control that is displayed as an <code>ItemTemplate</code> and in the same <code>GridView</code> I have a regular <code>Button</code> control to which I added some code like this. </p>

<pre><code> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "addToSession")
    {
        //get the row index stored in the CommandArgument property
        int index = Convert.ToInt32(e.CommandArgument);

        //get the gridview row where the command is raised
        GridViewRow selectedRow = ((GridView)e.CommandSource).Rows[index];

        //values stored in the text property of the cells
        string ISBN = selectedRow.Cells[0].Text;
        string bookTitle = selectedRow.Cells[1].Text;
        string image = selectedRow.Cells[2].Text;

        Service s = new Service();
        Session["ISBN"] = ISBN;
        Session["bookTitle"] = bookTitle;
        Session["ImageUrl"] = s.returnImageUrl(bookTitle);

        if (Session["userName"] == null)
        {
            Response.Redirect("registerPage.aspx");
        }
        else
        {
            Response.Redirect("RateBook.aspx");
        }
    }
    else if (e.CommandName == "ratedBooks")
    {
        int index = Convert.ToInt32(e.CommandArgument);

        GridViewRow selectedRow = ((GridView)e.CommandSource).Rows[index];

        string bookTitle = selectedRow.Cells[1].Text;

        Service s = new Service();

        Session["ImageUrl"] = s.returnImageUrl(bookTitle);

        Response.Redirect("BookRated.aspx");
    }
</code></pre>

<p>when I run this code I get a format exception and again I am not sure why.
I have altered the image button a bit and nested the image in a link button which seems to be more correct.</p>

<pre><code>&lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;
                    &lt;asp:LinkButton ID="LinkButton1" runat="server" CommandName="ratedBooks"&gt;
                        &lt;asp:Image ID="ImageButton1" ImageUrl='&lt;%#Eval("pictureUrl") %&gt;'
                            runat="server" /&gt;   

                    &lt;/asp:LinkButton&gt;    

                &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
</code></pre>

<p>Advice perhaps as to what to do</p>

<p>regards</p>
