Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
public void fnsave()
        {
            int i = 0;

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                bool status = false;
                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();
        }
Posted
Comments
Kees van Spelde 11-Jan-14 9:07am    
Where is your database logic? You need to do an update query somewhere.
ZurdoDev 11-Jan-14 22:27pm    
You'll have to step through the code and see what is happening. We can't do that for you.
Please debug and see what is happening and if you are facing any exception, just let us know.

1 solution

C#
try
            {

                oledbCmdBuilder = new OleDbCommandBuilder(oledbAdapter);
                changes = ds.GetChanges();
                if (changes != null)
                {
                    oledbAdapter.Update(ds.Tables[0]);
                }
                ds.AcceptChanges();
                MessageBox.Show("Save Changes", "Saved?", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                Frm_Reports obj = new Frm_Reports();
                obj.Show();
            }



            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

try this code is working fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900