Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
how to get row index
posted

 I added a linkbutton in a TemplatedField in a WebGrid.When I Click the LinkButton,How To Get the Row index in LinkButton Click event??

Parents
  • 479
    posted

     Alternatively -

    templated column markup:

                            <igtbl:TemplatedColumn>
                                <CellTemplate>
                                    <asp:LinkButton runat="server" ID="lblName" Text='<%# Eval("BoundColumnName") %>' CommandName="YourCommandName" CommandArgument="<%# Container.Cell.Row.Index %>" OnCommand="OnButtonCommand" />
                                </CellTemplate>
                            </igtbl:TemplatedColumn>

     Code behind:

            protected void OnButtonCommand(object sender, CommandEventArgs e)
            {
                LinkButton btn = (LinkButton)sender;
                int rowIndex = int.Parse(btn.CommandArgument);
            }


     


     

Reply Children