Show/Hide column of DataGridView from DB

1. Get list of record from DB:

      List<CheckList> listOfCheckList = db.CheckLists.ToList() ;

2. Create BindingList
            checkListBL = new BindingList<CheckList>(listOfCheckList);
            CheckListDGV.DataSource = checkListBL;

3. Set Visible for columns:
         
            CheckListDGV.Columns["CheckListId"].Visible = false;
            CheckListDGV.Columns["CheckListQuestions"].Visible = false;

4 Reload DataGridView:

            CheckListDGV.Refresh();

Comments

Popular posts from this blog

ASP Net API pass parameter frombody

Using Microsoft.Office.Interop.Word and Excel in ASP NET Web App