private void BindGridSelect()
        {
            TrainTypeTaskBLL      objBll  = new TrainTypeTaskBLL();
            IList <TrainTypeTask> objList = objBll.GetTrainTypeTaskByTrainTypeID(Convert.ToInt32(ViewState["TrainTypeID"].ToString()));

            Grid2.DataSource = objList;
            Grid2.DataBind();
        }
        private ArrayList GetPaperList()
        {
            TrainTypeTaskBLL      objBll      = new TrainTypeTaskBLL();
            IList <TrainTypeTask> objTaskList = objBll.GetTrainTypeTaskByTrainTypeID(Convert.ToInt32(ViewState["TrainTypeID"].ToString()));
            ArrayList             objList     = new ArrayList();

            if (objTaskList.Count > 0)
            {
                foreach (TrainTypeTask obj in objTaskList)
                {
                    objList.Add(obj.PaperID);
                }
            }

            return(objList);
        }
        protected void btnDel_Click(object sender, EventArgs e)
        {
            TrainTypeTaskBLL objBll = new TrainTypeTaskBLL();

            GridItemCollection activeItems = Grid2.GetCheckedItems(Grid2.Levels[0].Columns[0]);

            foreach (GridItem activeItem in activeItems)
            {
                TrainTypeTask obj = new TrainTypeTask();
                obj.TrainTypeID = Convert.ToInt32(ViewState["TrainTypeID"].ToString());
                obj.PaperID     = Convert.ToInt32(activeItem[1]);

                objBll.DelTrainTypeTask(obj.TrainTypeID, obj.PaperID);
            }
            BindGrid();
            BindGridSelect();
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            TrainTypeTaskBLL objBll  = new TrainTypeTaskBLL();
            ArrayList        objList = GetPaperList();

            GridItemCollection activeItems = Grid1.GetCheckedItems(Grid1.Levels[0].Columns[0]);

            foreach (GridItem activeItem in activeItems)
            {
                if (objList.IndexOf(activeItem[1]) == -1)
                {
                    TrainTypeTask obj = new TrainTypeTask();
                    obj.TrainTypeID = Convert.ToInt32(ViewState["TrainTypeID"].ToString());
                    obj.PaperID     = Convert.ToInt32(activeItem[1]);

                    objBll.AddTrainTypeTask(obj);
                }
            }
            BindGrid();
            BindGridSelect();
        }