예제 #1
0
        private void ImportToGrid(string FilePath, string Extension)
        {
            String           connectionString = getExcelConnectionString(Extension, RadioButtonListHDR.SelectedItem.Text);
            OleDbConnection  conExcel         = new OleDbConnection(connectionString);
            OleDbCommand     cmdExcel         = new OleDbCommand();
            OleDbDataAdapter oda = new OleDbDataAdapter();

            cmdExcel.Connection = conExcel;

            String SheetName = ddlSheets.SelectedItem.Text;

            conExcel.Open();
            cmdExcel.CommandText = "Select * from [" + SheetName + "]";
            oda.SelectCommand    = cmdExcel;
            oda.Fill(dt);
            conExcel.Close();

            //Bind data to GridView

            GridViewStudents.Caption    = Path.GetFileName(FilePath);
            GridViewStudents.DataSource = dt;
            tempGridView.DataSource     = dt; //invisible temporary gridview to load all data in excel without paging
            GridViewStudents.DataBind();
            tempGridView.DataBind();
        }
예제 #2
0
        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {
            // int Aid = Convert.ToInt32(Session["id"].ToString().Trim());

            int pagesize = Convert.ToInt32(ddlPageSize.SelectedValue);
            //int pageIndex = int.Parse((sender as LinkButton).CommandArgument);

            int totalRows = 0;
            //Response.Write("Sort Expression = " + e.SortExpression);
            //Response.Write("<br/>");
            //Response.Write("Sort Direction = " + e.SortDirection.ToString());

            SortDirection sortDirection = SortDirection.Ascending;
            string        sortField     = string.Empty;

            SortGridview((GridView)sender, e, out sortDirection, out sortField);
            string strSortDirection = sortDirection == SortDirection.Ascending ? "ASC" : "DESC";


            GridViewStudents.DataSource = commancode.GetStudents(1, pagesize, e.SortExpression,
                                                                 strSortDirection, "allrep", out totalRows);

            GridViewStudents.DataBind();

            DatabindRepeater(1, pagesize, totalRows);
        }
예제 #3
0
 protected void PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     ImportToGrid(FilePath, Extension);
     GridViewStudents.DataSource = dt;
     GridViewStudents.PageIndex  = e.NewPageIndex;
     GridViewStudents.DataBind();
 }
예제 #4
0
        private void LoadDataFromCacheForStudent()
        {
            DataSet ds = (DataSet)Cache["DATASETSTUDENT"];

            GridViewStudents.DataSource = ds.Tables["UserStudent"];
            GridViewStudents.DataBind();
        }
예제 #5
0
        protected void GridViewStudents_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            ClassStudents searchStudent = new ClassStudents();

            searchStudent.SearchStudent(ddStudentSearch, txStudentSearch, GridViewStudents);
            GridViewStudents.PageIndex = e.NewPageIndex;
            GridViewStudents.DataBind();
        }
        protected void GridViewStudents_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            ClassStudents loadDetails = new ClassStudents();

            loadDetails.LoadStudentDetailsToStudentGrade(GridViewStudents);
            GridViewStudents.PageIndex = e.NewPageIndex;
            GridViewStudents.DataBind();
        }
예제 #7
0
        public void BindGridcourior()
        {
            SqlParameter parameter = new SqlParameter();

            parameter.ParameterName     = "@Action";
            parameter.Value             = "allrep";
            GridViewStudents.DataSource = commancode.GetData("Sp_GetCatagories", parameter);
            GridViewStudents.DataBind();
        }
예제 #8
0
        public void DataSearch(string SearchKey)
        {
            string query = @"SELECT * FROM Students WHERE Name LIKE '%" + SearchKey + "%' OR Fathers_name LIKE '%" + SearchKey + "%' OR Mothers_name LIKE '%" + SearchKey + "%' OR Date_of_Admission LIKE '%" + SearchKey + "%' OR Gender LIKE '%" + SearchKey + "%' OR Class LIKE '%" + SearchKey + "%' OR Class_Roll LIKE '%" + SearchKey + "%' OR Address LIKE '%" + SearchKey + "%'";

            GridViewStudents.DataSource = dm.GetDataTable(query);
            GridViewStudents.DataBind();
            if (dm.count == 0)
            {
                lblSearchResult.Text = "Sorry! no data found";
            }
            else
            {
                lblSearchResult.Text = "";
            }
        }
예제 #9
0
        private void gridbind()
        {
            int pagesize = Convert.ToInt32(ddlPageSize.SelectedValue);
            //int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
            // int Aid = Convert.ToInt32(Session["id"].ToString().Trim());

            int totalRows = 0;

            GridViewStudents.DataSource =
                commancode.GetStudents(1, pagesize, "surname ",
                                       "ASC", "allrep", out totalRows);

            GridViewStudents.DataBind();

            DatabindRepeater(1, pagesize, totalRows);
        }
예제 #10
0
        protected void TextBoxsearch_TextChanged(object sender, EventArgs e)
        {
            // int Aid = Convert.ToInt32(Session["id"].ToString().Trim());

            int pagesize = Convert.ToInt32(ddlPageSize.SelectedValue);
            //int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
            string search    = TextBoxsearch.Text.ToString().Trim();
            int    totalRows = 0;

            GridViewStudents.DataSource =
                commancode.GetStudents(1, pagesize, "surname ",
                                       "ASC", "allrep", out totalRows, search);

            GridViewStudents.DataBind();

            DatabindRepeater(1, pagesize, totalRows);
        }
예제 #11
0
        public void LoadGridViewStudents()
        {
            string query = @"SELECT [ID]
                                   ,[Name]
                                   ,[Fathers_name]
                                   ,[Mothers_name]
                                   ,[Date_of_Birth]
                                   ,[Date_of_Admission]
                                   ,[Gender]
                                   ,[Class]
                                   ,[Class_Roll]
                                   ,[Phone]
                                   ,[Email]
                                   ,[Address]
                               FROM [dbo].[Students]";

            GridViewStudents.DataSource = dm.GetDataTable(query);
            GridViewStudents.DataBind();
        }
예제 #12
0
        protected void Page_Changed(object sender, EventArgs e)
        {
            //int Aid = Convert.ToInt32(Session["id"].ToString().Trim());

            int pagesize  = Convert.ToInt32(ddlPageSize.SelectedValue);
            int pageIndex = int.Parse((sender as LinkButton).CommandArgument);

            int totalRows = 0;

            GridViewStudents.DataSource =
                commancode.GetStudents(pageIndex, pagesize, "surname ",
                                       "ASC", "allrep", out totalRows);

            GridViewStudents.DataBind();

            DatabindRepeater(pageIndex, pagesize, totalRows);

            //this.GetStudentssPageWise(pageIndex);
            UpdatePanelgridview.Update();
        }
예제 #13
0
        private void LoadFromDatabaseForStudent()
        {
            string        connStr = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection conn    = new SqlConnection(connStr);

            string            sql = "select u.ID, u.Password, s.Name, s.Gender, s.Email, s.Cgpa, s.CreditsCompleted, s.Semester from UserInfo u, Student s where u.ID = s.StudentId";
            SqlDataAdapter    AdapterUserStudent = new SqlDataAdapter(sql, conn);
            SqlCommandBuilder builder            = new SqlCommandBuilder(AdapterUserStudent);
            DataSet           ds = new DataSet();

            AdapterUserStudent.Fill(ds, "UserStudent");

            sql = "select * from UserInfo";
            SqlDataAdapter AdapterUserInfo = new SqlDataAdapter(sql, conn);

            builder = new SqlCommandBuilder(AdapterUserInfo);
            AdapterUserInfo.Fill(ds, "UserInfo");

            sql = "select * from Student";
            SqlDataAdapter AdapterStudent = new SqlDataAdapter(sql, conn);

            builder = new SqlCommandBuilder(AdapterStudent);
            AdapterStudent.Fill(ds, "Student");

            ds.Tables["UserStudent"].PrimaryKey = new DataColumn[] { ds.Tables["UserStudent"].Columns["ID"] };
            ds.Tables["UserInfo"].PrimaryKey    = new DataColumn[] { ds.Tables["UserInfo"].Columns["ID"] };
            ds.Tables["Student"].PrimaryKey     = new DataColumn[] { ds.Tables["Student"].Columns["StudentId"] };

            GridViewStudents.DataSource = ds.Tables["UserStudent"];
            GridViewStudents.DataBind();

            Cache["DATASETSTUDENT"]     = ds;
            Cache["AdapterUserStudent"] = AdapterUserStudent;
            Cache["AdapterUserInfo"]    = AdapterUserInfo;
            Cache["AdapterStudent"]     = AdapterStudent;
        }