I want to update the datagridview values into database through checkbox that is in datagridview

440 Views Asked by At
public void fnsave()    
{  
    int i = 0;
    bool status = false;
    foreach (DataGridViewRow row in dataGridView1.Rows)
    {
        if (Convert.ToBoolean(String.IsNullOrEmpty(row.Cells["AllowAction"].Value.ToString().Trim()) ? 
                      "False" : row.Cells["AllowAction"].Value.ToString()))
        {
            string modulename = row.Cells["ModuleName"].Value.ToString();
            status = true;
            i = user.SavePermission(Convert.ToInt32(cmbPermissions.SelectedValue), modulename, 
                Convert.ToBoolean(row.Cells["AllowAction"].Value.ToString()));
        }
        if (i > 0)
        {
            MessageBox.Show("Permission Details Added Successfully");
        }
        else
        {
            status = false;
        }
    }
}
private void btnUpdate_Click(object sender, EventArgs e)
{
    fnsave();
}
0

There are 0 best solutions below