Vikas Ahlawat

Vikas Ahlawat

  • NA
  • 564
  • 819.1k

how determine that which CommandField is selected on SelectedIndexChanged event?

Mar 5 2011 2:02 AM
I have a GridView with 2 CommandFields (Edit and Delete), how can I
determine in the SelectedIndexChanged event which CommandField is
clicked?
for some resion i can't use CommandName and commandargument . So i want to do it by CommandField


                                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                                                Font-Names="Trebuchet MS" Font-Size="9pt" ForeColor="#0000CC"
                                                 Width="100%"
                                                onpageindexchanging="GridView1_PageIndexChanging"
                                                onselectedindexchanged="GridView1_SelectedIndexChanged"
                                                onrowcommand="GridView1_RowCommand">
                                                <PagerSettings Position="Top" />
                                                <RowStyle ForeColor="Black" HorizontalAlign="Left" />
                                                <Columns>
                                                    <asp:CommandField HeaderText="Action" SelectText="Edit" ShowSelectButton="True">
                                                        <HeaderStyle BackColor="#CCCCCC" Font-Names="Trebuchet MS" Font-Size="9pt"
                                                            ForeColor="#0000CC" HorizontalAlign="Center" />
                                                        <ItemStyle ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                    </asp:CommandField>
                                                    <asp:CommandField HeaderText="Action" SelectText="Delete" ShowSelectButton="True">
                                                        <HeaderStyle BackColor="#CCCCCC" Font-Names="Trebuchet MS" Font-Size="9pt"
                                                            ForeColor="#0000CC" HorizontalAlign="Center" />
                                                        <ItemStyle ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                    </asp:CommandField>
                                                </Columns>
                                                <HeaderStyle BackColor="#CCCCCC" HorizontalAlign="Left" />
                                            </asp:GridView>




Answers (1)