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
895
Which row is the button in when it was clicked?
posted

Hi,

I'm using a WebHierarchicalDataGrid .NET control.

I've added a button to a column and wired up the click event to the aspx.cs code.

I'm able to click the button and the click event fires.

However, I don't have a clue as to which row the user was on when they clicked the button.

protected void DeactivateNow_Click(object sender, EventArgs e)

The sender seems to be the button I just clicked on.

How do I access the data in the row the button is in?

Thanks,

Brian.

Parents
  • 29417
    Verified Answer
    Offline posted

    Hello demoend ,

     

    Thank you for contacting Infragistics Developer Support.

     

    You can access the row the template element belongs to in the following way:

    1)Get the sender and cast hit to a button.

    2)Access the Template Container that the button is located in trough the button’s Parent element.

    3)From there access the item element and this will get you the actual grid record. From there you can access the row, columns, grid container and so on.

     

    Here’s a code example in c#:

     

    protected void button_Click(object sender, EventArgs e)

        {

            Button btn = (Button)sender;

     

            TemplateContainer parent =(TemplateContainer) btn.Parent;

     

            GridRecordItem item =(GridRecordItem)(parent.Item);

            

     

            //this returns the index of the row in the container

            int indexRow = item.Row.Index;

    }

     

    I’m also attaching a sample for your reference. Let me know if you need further assistance with this issue.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://es.infragistics.com/support

     

Reply Children
No Data