Getting values from a Datagrid
-
Hey everyone, I have a ASP.NET C# website. On one of my pages I have a datagrid and when the user clicks on the surname it has to pass two values. One is the student ID and the other is the TB_ID. I made the student ID the ItemIndex field so that was easy to get when you click on a student. But I cannot get the TB_ID value from the grid when you click on the surname. This is the code so far: // find student id and training block for selected record stPersId = dgGrpReport.DataKeys[e.Item.ItemIndex].ToString(); //TBID = dgGrpReport.Columns(rows[1]).ToString(); //TBID = ((Label)dgGrpReport.SelectedItem.Cells[1].FindControl("TB_ID")).Text; //TBID = e.Item.ItemIndex[1].ToString(); //TBID = dgGrpReport.SelectedItem.Cells(1).Text; Response.Write(TBID + " - " + stPersId); As you can see I've tried a few combinations. Any ideas? Thanks of course in advance, I appreciate the help! Michael