finding the contents of a cell in a datagrid
-
Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve
-
Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve
Have you tried using a hyperlink column? Not sure if this will work for you but you could have column 1 with text 'View Details' and have this as a link to another page displaying the customer info. Something like this... private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e){ //cast to dataGrid as that is what you are using DataGrid grid = (DataGrid)sender; //redirect to page you display customer info in passing customer number from column 1 (column 0 is your hyperlink column) string page = "newpage.aspx?id=" + grid.Items[grid.SelectedIndex].Cells[1].Text; Response.Redirect(page,true); } Just an idea! Colin
-
Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve