Identify which button clicked in Gridview

Apr 5 2012 2:41 AM
Hi All,

I have a Gridview in my webpage and there are two button fields included in gridview for selection. One is for "Adding" and other one is for "Editing".
How can i track which button is clicked inside GridView1_SelectedIndexChanged Event? Simply what i want is to get the cell id or the button id of the button clicked. Can anybody give me a hand to sort this out ?


****this is my gridview columns*****

                                <Columns>
                                <asp:CommandField ShowSelectButton="True" ButtonType="Image"
                                        SelectImageUrl="~/images/addNew.png" SelectText="select" >
                                        <ControlStyle Width="15px" />
                                    <HeaderStyle Wrap="True" />
                                    </asp:CommandField>
                                        <asp:CommandField ShowSelectButton="True" ButtonType="Image"
                                        SelectImageUrl="~/images/edit.png" SelectText="edit" >
                                    <ControlStyle Width="15px" />
                                    </asp:CommandField>
                                </Columns>



*******this is my Event***********

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
//code goes here
    }

Thanks,
Max

Answers (4)