Dear all,
aspx file

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CellPadding="10" CellSpacing="1" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <Columns>
                	<asp:BoundField DataField="g_id" HeaderText="S.no" ReadOnly="True"/>
                    <asp:BoundField DataField="gcdate" HeaderText="Date" />
                    <asp:BoundField DataField="gc_no" HeaderText="G.c #" />
                    <asp:BoundField DataField="consignor_detail" HeaderText="Consignor" />
                    <asp:BoundField DataField="consignee_detail" HeaderText="Consignee" />
                    <asp:BoundField DataField="qty" HeaderText="Nos" />
                    <asp:BoundField DataField="package_type" HeaderText="Contains" />
                    <asp:BoundField DataField="total_amount" HeaderText="Amount" />
                    <asp:BoundField DataField="acc_type" HeaderText="Remark" />
                    <asp:BoundField DataField="loading_status" HeaderText="Status" />
                    <asp:CommandField ButtonType="Image" SelectImageUrl="images/icon1.gif"  ShowSelectButton="True" />
                    <asp:CommandField ButtonType="Image" SelectImageUrl="images/icon2.gif" ShowSelectButton="True" />
                    
                </Columns>
        
        </asp:GridView>

aspx.cs file

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
       TextBox1.Text= GridView1.SelectedRow.Cells[0].Text;
       
       Response.Redirect("View_Gcdetails.aspx?Id=" + TextBox1.Text);
    }

i have 2 image button. when i click the image button1 it go view_gcdetails.aspx page and click the image button2 it go view_gcdetails2.aspx page any one solve the problem and code

regards
sathish

kvprajapati commented: Please do not misuse our kindness. 43 posts and still struggling with [code] tags? -1

any one solve the problem and code

I don't think that there is any problem with code you posted here except you didn't use code-tags.

i have 2 image button.

Learn to set CommandName property.

<asp:CommandField ButtonType="Image"
                                 SelectImageUrl="images/icon1.gif"
                                 ShowSelectButton="True"
                                 CommandName="Action1"
 />
<asp:CommandField ButtonType="Image"
                                 SelectImageUrl="images/icon2.gif" 
                                 ShowSelectButton="True" 
                                 CommandName="Action2"
/>

when i click the image button1 it go view_gcdetails.aspx page and click the image button2 it go view_gcdetails2.aspx page.

Add handler for RowCommand event,

void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) {
   if(e.CommandName=="Action1") {
       //
   }
   else
   if(e.CommandName=="Action2"){
      //
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.