protected void ViewDetails(object sender, GridViewSelectEventArgs e) { GridViewRow row = grid.Rows[e.NewSelectedIndex]; string orderid = dt1.Rows[row.DataItemIndex]["OrderID"].ToString(); string message = BLL.GetOrderDetails(orderid); DialogResult dialogResult = MessageBox.Show(message, "View", MessageBoxButtons.OK); if (dialogResult == DialogResult.OK) { } System.Diagnostics.Debug.WriteLine(orderid); }