try { for (int i = 0; i < dataGrid.Items.Count; i++) { DataRowView dataRowView = (DataRowView)((Button)e.Source).DataContext; String ProductName = dataRowView[1].ToString(); String ProductDescription = dataRowView[2].ToString(); id = dataRowView[0].ToString(); if ((sender as CheckBox).IsChecked == true) { { Assign = "True"; } } else { { Assign = "False"; } } SqlConnection con = new SqlConnection(Globals.ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("sp_mod_assign", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@mod_id", SqlDbType.Int).Value = string.IsNullOrWhiteSpace(id) ? DBNull.Value : (object)id; cmd.Parameters.AddWithValue("@assign", SqlDbType.VarChar).Value = string.IsNullOrWhiteSpace(Assign) ? DBNull.Value : (object)Assign; cmd.ExecuteNonQuery(); con.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); }
private void CheckBox_Checked(object sender, RoutedEventArgs e) { DataRowView row; row = (DataRowView)((CheckBox)e.OriginalSource).DataContext; //row["Assign"] = "True"; }
private void CheckBox_Unchecked(object sender, RoutedEventArgs e) { DataRowView row; row = (DataRowView)((CheckBox)e.OriginalSource).DataContext; //row["Assign"] = "False"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)