TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mayank Jani
NA
477
76.7k
To fetch database value in CheckedListBox as Checked.
May 1 2017 1:45 AM
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
Reply
Answers (
2
)
Filling datagridview cells after validating first row in C#
What is async And await ?? And Why used in async and await