Dear All,
I am developing a C# Windows application with MS Access database. There is one form containing a DataGridView and a CheckedListBox.
when the form gets load, all user names appear in the GridView and User Rightes in the CheckedListBox from two different tables. I select a user from DataGridView and then i select the user rights from CheckedListBox and this data saves in a third table by clicking a CommandButton.
my problem is how to fetch the same data from the third table and get the checked list box checked according to the data from the database? i use dataset to fetch the record but i dont know how to get the checked list box checked.
the table has only two fields UserName and UserRights. both are text field.
i use code ...
private void dgvUsers_CellClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Select * From UserRights Where UserId=" + dgvUsers.Rows[dgvUsers.CurrentRow.Index].Cells[dgvUsers.CurrentCell.ColumnIndex].FormattedValue.ToString());
OleDbDataAdapter ShowRights = new OleDbDataAdapter("Select * From UserRights Where UserId=" + "'dgvUsers.Rows[dgvUsers.CurrentRow.Index].Cells[dgvUsers.CurrentCell.ColumnIndex].FormattedValue.ToString()'", myconn);
DataSet dsShowRights = new DataSet();
ShowRights.Fill(dsShowRights);
if (dsShowRights.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in dsShowRights.Tables)
{
//???
}
}
Please Help...
Thank You.
Mayank Jani