I have I have 2 grid views. Gridview1 has details of Bicycles which are available for rent. Gridview1 also has a button. When button on gridview1 is clicked the concerned row should get added on to gridview2
Gridview2 is bikes selected from gridview1. I have tried writting that code but it doesn't work.
Below is my code
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["IndBikeID"].Value.ToString());
SqlConnection con = Database.GetCnn();
con.Open();
string command = "select * from Bike_IndividualBike Where Bike_IndividualBike.Status = 'Available' AND IndBikeID=" + id + "";
SqlCommand cmd = new SqlCommand(command, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
}
}
I am not sure what to put in the foreach loop.
Also why do we need int id variable?
Can someone please help me. The project is for renting bicycle.