Get GridView row index from a template field button

toxicaid

New Member
first question:I have a gridview 'gvSnacks' with a list of snacks and prices. The first column of the gridview is a templatefield with the button 'btnAdd'.When one of the add buttons is clicked I want it to assign that rows value to an integer so I can retrieve additional data from that row.This is what I have, but I've hit a dead end.\[code\]protected void btnAdd_Click(object sender, EventArgs e){ int intRow = gvSnacks.SelectedRow.RowIndex; string strDescription = gvSnacks.Rows[intRow].Cells[2].Text; string strPrice = gvSnacks.Rows[intRow].Cells[3].Text;}\[/code\]Appreciate any help!
 
Back
Top