suppose if we are using a Template control to place so many controls in a gridrow and we need to track the row from which control has generated an event in such a case we can use the following code.
protected void btnCart_Click(object sender, EventArgs e)
{
Button btn= (Button)sender;
GridViewRow grdRow =(GridViewRow) btn.Parent.Parent;
}
Here i have a button inside my template control and once i click my button from a data row i can create an object of the row that has generated the click event.
by using the grdRow instance you can acess the elements within that row.
Label lbProdTitle = (Label)(grdRow.Cells[0].FindControl("fldPropertyTitleLabel1"));
Label lbPrice = (Label)(grdRow.Cells[0].FindControl("fldPrice"));
with regards,
Praveen
www.linesandgraphs.com
No comments:
Post a Comment