-1

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Votes + Comments
Please do not misuse our kindness. 43 posts and still struggling with [code] tags?
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0

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"){
      //
   }
}

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.