Wednesday, October 3, 2012

Getting the Repeater row index from the LinkButton


This is one I am posting for my own reference so I can find it easier...  When Clicking a LinkButton in a Repeater, I needed the index available to modify a cached DataTable.

Situation:  Getting the Repeater row index from the LinkButton

Solution:

        LinkButton lnkButton = sender as LinkButton;
        int RepeaterItemIndex = ((RepeaterItem)lnkButton.NamingContainer).ItemIndex;

Credit to kaushalparik27 at http://forums.asp.net/t/1333400.aspx/1

Tuesday, October 2, 2012

Scroll after postback


Situation: Button inside of a GridView fires the Command event and needs to scroll to the bottom of the page.

Solution:  Use an anchor tag, then use ClientScript.RegisterStartupScript on the end of the event method to scroll to it.

Credit goes to http://forums.asp.net/t/1311972.aspx/1