protected void btnBackword_Click(object sender, EventArgs e)
        {
            try
            {

                int[] arr = lstcategory.GetSelectedIndices();
                ListItem[] li = new ListItem[arr.Length];
                int cnt = 0;
                foreach (GridViewRow row in gridStudentInfo.Rows)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        int FlagId = Convert.ToInt16(row.Cells[4].Text);
                        int ListFlagId = Convert.ToInt16(lstcategory.Items[arr[i]].Value.ToString());
                        if (FlagId == ListFlagId)
                        {
                            row.Visible = true;
                            li[cnt] = new ListItem(lstcategory.Items[arr[i]].Text, lstcategory.Items[arr[i]].Value.ToString());
                            cnt++;

                        }
                    }
                }

                for (int i = 0; i < li.Count(); i++)
                {
                    lstcategory.Items.Remove(li[i]);
                }

            }
            catch (Exception ex)
            {

            }
        }
        public void GetCourseList()
        {
            DropDownListCourse.Items.Clear();
            try
            {
                ListItem[] _listCourse = _inBloomApi.GetCourseBySchool(DropDownListSchool.SelectedItem.Value.ToString());
                _user = (User)Session["UserDetail"];

                if (_user.IsAdminUser || IsLeader())
                {
                    _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value);

                    //_sectionAndCourseOfferingId=> sectionid and courseofferingid
                    ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList();
                    ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()];
                    ListItem[] _courseIdAndCourseOfferingId = new ListItem[_sectionAndCourseOfferingId.Count()];

                    for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++)
                    {
                        ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value);
                        _temp[i] = new ListItem(_course.Text, _course.Value);
                        _courseIdAndCourseOfferingId[i] = new ListItem(_course.Value, _sectionAndCourseOfferingId[i].Value);

                    }

                    DropDownListCourse.Items.AddRange(_temp);
                    Course course = new Course(_temp);
                    Session["Course"] = course;
                    Session["SectionAndCourseOfferingId"] = _sectionAndCourseOfferingId;
                    Session["CourseIdAndCourseOfferingId"] = _courseIdAndCourseOfferingId;

                }
                else
                {

                    if (!IsEducator())
                    {
                        _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value);
                    }
                    else
                    {
                        _inBloomApi.GetSectionListForLoginUser();
                    }
                    ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList();
                    ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()];
                    ListItem[] _courseIdAndCourseOfferingId = new ListItem[_sectionAndCourseOfferingId.Count()];
                    if (_listCourse != null)
                    {

                        for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++)
                        {
                            ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value);

                            // check more than one course
                            bool IsCoursePresent = false;
                            for (int j = 0; j < _temp.Count(); j++)
                            {
                                if (_temp[j] != null)
                                {
                                    if (_temp[j].Value == _course.Value)
                                    {
                                        IsCoursePresent = true;
                                        break;
                                    }
                                }
                            }

                            if (IsCoursePresent)
                            {
                            }
                            else
                            {
                                _temp[i] = new ListItem(_course.Text, _course.Value);
                            }
                            _courseIdAndCourseOfferingId[i] = new ListItem(_course.Value, _sectionAndCourseOfferingId[i].Value);

                            //for (int Index = 0; Index < _listCourse.Count(); Index++)
                            //{
                            //    bool Find = _inBloomApi.IsSectionContainOfferingOfThisCourse(_sectionAndCourseOfferingId[i].Value, _listCourse[Index].Value);
                            //    if (Find)
                            //    {
                            //        _temp[i] = new ListItem(_listCourse[Index].Text, _listCourse[Index].Value);
                            //        _courseIdAndCourseOfferingId[i] = new ListItem(_listCourse[Index].Value, _sectionAndCourseOfferingId[i].Value);
                            //        break;
                            //    }
                            //}
                        }

                        //DropDownListCourse.Items.AddRange(_listCourse);
                        //Course course = new Course(_listCourse);
                        //Session["Course"] = course;

                        for (int i = 0; i < _temp.Count(); i++)
                        {
                            if (_temp[i] != null)
                                DropDownListCourse.Items.Add(_temp[i]);
                        }

                        // DropDownListCourse.Items.AddRange(_temp);
                        Course course = new Course(_temp);
                        Session["Course"] = course;
                        Session["SectionAndCourseOfferingId"] = _sectionAndCourseOfferingId;
                        Session["CourseIdAndCourseOfferingId"] = _courseIdAndCourseOfferingId;
                    }
                    else
                    {
                        Session["Course"] = null;
                    }

                }

            }
            catch (Exception ex)
            {
            }
        }
        public void GetCourseListNew()
        {
            try
            {
                _user = (User)Session["UserDetail"];
                DropDownListCourse.Items.Clear();
                ListItem[] _sectionList = null;
                if (_user.IsAdminUser || IsLeader())
                {
                    _sectionList = _inBloomApi.GetSectionByStaffIdAndSchoolId(dropDownListStaff.SelectedItem.Value, DropDownListSchool.SelectedItem.Value);
                }
                else
                {
                    _sectionList = _inBloomApi.GetSectionListForLoginUser();
                }
                ListItem[] _sectionAndCourseOfferingId = _inBloomApi.GetSectionAndCourseOfferingIdList();
                ListItem[] _temp = new ListItem[_sectionAndCourseOfferingId.Count()];

                ListItem[] _courseAndSectionIdTemp = new ListItem[_sectionAndCourseOfferingId.Count()];
                ListItem[] _sectionAndCourseIdTemp = new ListItem[_sectionAndCourseOfferingId.Count()];

                for (int i = 0; i < _sectionAndCourseOfferingId.Count(); i++)
                {
                    ListItem _course = _inBloomApi.GetCourseBySectionCourseOfferingId(_sectionAndCourseOfferingId[i].Value);
                    bool IsPresent = false;
                    for (int j = 0; j < _temp.Count(); j++)
                    {
                        if (_temp[j] != null)
                        {
                            if (_temp[j].Value == _course.Value)
                            {
                                IsPresent = true;
                                break;
                            }

                        }

                    }
                    if (!IsPresent)
                    {
                        _temp[i] = new ListItem(_course.Text, _course.Value);

                    }
                    _courseAndSectionIdTemp[i] = new ListItem(_course.Value, _sectionList[i].Value);
                    _sectionAndCourseIdTemp[i] = new ListItem(_sectionList[i].Value, _course.Value);
                }

                for (int i = 0; i < _temp.Count(); i++)
                {
                    if (_temp[i] != null)
                    {
                        DropDownListCourse.Items.Add(_temp[i]);
                    }
                }
                //DropDownListCourse.Items.AddRange(_temp);

                Course course = new Course(_temp);
                Session["Course"] = course;
                Session["CourseAndSectionIdTemp"] = _courseAndSectionIdTemp;
                Session["SectionAndCourseIdTemp"] = _sectionAndCourseIdTemp;

            }
            catch (Exception Ex)
            {
            }
        }
        public Temp[] GetFlagListOfStaffForAdminUser(User _user, String EducationOrganizationId, ListItem[] _schoolList)
        {
            Temp[] _temp = null;
            try
            {
                for (int i = 0; i < _schoolList.Count(); i++)
                {
                    Temp[] _tempStaff = null;
                    JArray _staffResponse = JArray.Parse(RestApiHelper.CallApi("schools/" + _schoolList[i].Value + "/teacherSchoolAssociations/teachers", this._accessToken));
                    if (_staffResponse != null)
                    {
                        String CustomLink = "";
                        _tempStaff = new Temp[_staffResponse.Count()];
                        for (int Index = 0; Index < _staffResponse.Count(); Index++)
                        {
                            JArray Links = JArray.Parse(_staffResponse[Index]["links"].ToString());
                            for (int j = 0; j < Links.Count; j++)
                            {
                                String Relation = _authenticateUser.GetStringWithoutQuote(Links[j]["rel"].ToString());
                                if (Relation.Equals("custom"))
                                {
                                    CustomLink = _authenticateUser.GetStringWithoutQuote(Links[j]["href"].ToString());
                                    Temp _response = GetCustomForStaff(CustomLink);
                                    _tempStaff[Index] = new Temp();
                                    _tempStaff[Index] = _response;
                                    break;
                                }
                            }

                            if (_temp == null)
                            {
                                _temp = new Temp[_tempStaff.Count()];
                                for (int j = 0; j < _tempStaff.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _tempStaff[j];
                                }
                            }
                            else
                            {
                                // store _temp array into another
                                Temp[] _forTemp = new Temp[_temp.Count()];
                                for (int j = 0; j < _temp.Count(); j++)
                                {
                                    _forTemp[j] = new Temp();
                                    _forTemp[j] = _temp[j];
                                }

                                // get newly added staff temp
                                _temp = new Temp[_tempStaff.Count() + _temp.Count()];
                                for (int j = 0; j < _tempStaff.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _tempStaff[j];
                                }

                                // get previous staff
                                int k = 0;
                                for (int j = _tempStaff.Count(); j < _tempStaff.Count() + _forTemp.Count(); j++)
                                {
                                    _temp[j] = new Temp();
                                    _temp[j] = _forTemp[k];
                                    k = k + 1;
                                }
                            }

                        }

                    }
                }

                // check for the blank
                int totalBlank = 0;
                for (int i = 0; i < _temp.Count(); i++)
                {
                    if (_temp[i] == null)
                        totalBlank = totalBlank + 1;
                }

                Temp[] _returnTemp = new Temp[_temp.Count() - totalBlank];
                int p = 0;
                for (int i = 0; i < _temp.Count(); i++)
                {
                    if (_temp[i] != null)
                    {
                        _returnTemp[p] = new Temp();
                        _returnTemp[p] = _temp[i];
                        p++;

                    }
                }

                return _returnTemp;
            }
            catch (InRowChangingEventException Ex)
            {
                return null;
            }
        }