i create two radiobutton New and old and i want if user don't check any one the value saved null in database.
this is my code :-
for (int i = 0; i < dgv_Add_job_card.Rows.Count; i++)
{
s = "insert into Auto_Part_Details (Items_No, Job_Card, Value_Part, Auto_Parts_id, Repair_id, New_Old_Part, Provider_id, Installation_id, Notes) values (@Items_No, @Job_Card, @Value_Part,@Auto_Parts_id , @Repair_id,@New_Old_Part , @Provider_id, @Installation_id , @Notes)";
sCommand = new SqlCommand(s, con);
sCommand.Parameters.AddWithValue("@Items_No", dgv_Add_job_card.Rows[i].Cells[0].Value);
sCommand.Parameters.AddWithValue("@Job_Card", dgv_Add_job_card.Rows[i].Cells[1].Value);
sCommand.Parameters.AddWithValue("@Value_Part", dgv_Add_job_card.Rows[i].Cells[2].Value);
sCommand.Parameters.AddWithValue("@New_Old_Part", dgv_Add_job_card.Rows[i].Cells[5].Value);
sCommand.Parameters.AddWithValue("@Notes", dgv_Add_job_card.Rows[i].Cells[8].Value);
sCommand.Parameters.AddWithValue("@Auto_Parts_id", dgv_Add_job_card.Rows[i].Cells[9].Value);
sCommand.Parameters.AddWithValue("@Repair_id", dgv_Add_job_card.Rows[i].Cells[10].Value);
sCommand.Parameters.AddWithValue("@Provider_id", dgv_Add_job_card.Rows[i].Cells[11].Value);
sCommand.Parameters.AddWithValue("@Installation_id", dgv_Add_job_card.Rows[i].Cells[12].Value);
sCommand.ExecuteNonQuery();
}
What I have tried:
this value show in gridview and i save it from gridview to database