Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBox1.Text))
            {
                if (Session["studentDatatable"] != null)

                {
                    StudentDataSet.StudentsDataTable studentDatatable = (StudentDataSet.StudentsDataTable)Session["studentDatatable"];
                    GridView1.DataSource = studentDatatable;
                    GridView1.DataBind();
                }
            }
            else
            {
                StudentDataSet.StudentsDataTable studentDatatable = (StudentDataSet.StudentsDataTable)Session["studentDatatable"];

                GridView1.DataSource = from Student in studentDatatable
                                       where Student.Name.ToUpper().StartsWith(TextBox1.Text.ToUpper())
                                       select new
                {
                    Student.ID,
                    Student.Name,
                    Student.Gender,
                    Student.TotalMarks
                };
                GridView1.DataBind();
            }
        }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            StudentDataSet.StudentsDataTable studentsDataTable = (StudentDataSet.StudentsDataTable)Session["DATATABLE"];

            if (string.IsNullOrEmpty(TextBox1.Text))
            {
                GridView1.DataSource = from student in studentsDataTable
                                       select new
                {
                    student.ID,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                GridView1.DataBind();
            }
            else
            {
                GridView1.DataSource = from student in studentsDataTable
                                       where student.Name.ToString().ToUpper().StartsWith(TextBox1.Text.ToUpper().ToString())
                                       select new
                {
                    student.ID,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                GridView1.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // In this example a strongly typed DataSet is used.
                // In a strongly typed DataSet the table columns becomes properties and type (class) associated with each of the table columns is known at design time
                // A seperate defination of the class for the DataSet table is not needed, also do not have to map the class properties to the DataSet table columns, Which is required for not strongly typed DataSet.
                // This makes development much easier and reduces errors in coding.
                StudentDataSetTableAdapters.StudentsTableAdapter StudentsTableAdapater = new StudentDataSetTableAdapters.StudentsTableAdapter();
                StudentDataSet.StudentsDataTable StudentDataTable = new StudentDataSet.StudentsDataTable();

                StudentDataSetTableAdapters.EmailsTableAdapter EmailsTableAdapter = new StudentDataSetTableAdapters.EmailsTableAdapter();
                StudentDataSet.EmailsDataTable EmailDataTable = new StudentDataSet.EmailsDataTable();

                Session["STUDENTDATATABLE"] = StudentDataTable;
                Session["EMAILDATATABLE"]   = EmailDataTable;

                StudentsTableAdapater.Fill(StudentDataTable);
                EmailsTableAdapter.Fill(EmailDataTable);

                GrdvStudents.DataSource = from student in StudentDataTable
                                          // As it is a strongly typed DataSet, the type (Class) of table is known at design time and,
                                          // all table columns are properties.
                                          select new
                {
                    student.Id,
                    student.FirstName,
                    student.LastName,
                    studentEmail = GetStudentEmails(student.Id),                           // New property can be defined if additional information needs to be added as one more column programatically.
                };

                GrdvStudents.DataBind();
            }
        }
Ejemplo n.º 4
0
        protected void Btn_Search_Click(object sender, EventArgs e)
        {
            StudentDataSet.StudentsDataTable sdt = (StudentDataSet.StudentsDataTable)Session["DATATABLE"];

            if (string.IsNullOrEmpty(Txt_Input.Text))
            {
                Gvw_Display.DataSource = from student in sdt
                                         select new
                {
                    student.Id,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                Gvw_Display.DataBind();
            }
            else
            {
                Gvw_Display.DataSource = from student in sdt
                                         where student.Name.ToUpper().Contains(Txt_Input.Text.ToUpper())
                                         select new
                {
                    student.Id,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                Gvw_Display.DataBind();
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StudentDataSetTableAdapters.StudentsTableAdapter studentsTableAdapter = new StudentDataSetTableAdapters.StudentsTableAdapter();
                StudentDataSet.StudentsDataTable studentsDataTable = new StudentDataSet.StudentsDataTable();
                studentsTableAdapter.Fill(studentsDataTable);

                Session["DATATABLE"] = studentsDataTable;

                GridView1.DataSource = from student in studentsDataTable
                                       select new { student.ID, student.Name, student.Gender, student.TotalMarks };
                GridView1.DataBind();
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StudentDataSetTableAdapters.StudentsTableAdapter sta = new StudentDataSetTableAdapters.StudentsTableAdapter();
                StudentDataSet.StudentsDataTable sdt = new StudentDataSet.StudentsDataTable();
                sta.Fill(sdt);

                Session["DATATABLE"] = sdt;


                Gvw_Display.DataSource = from student in sdt
                                         select new
                {
                    student.Id,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                Gvw_Display.DataBind();
            }
        }
Ejemplo n.º 7
0
        protected void BtnSeachStudent_Click(object sender, EventArgs e)
        {
            if (Session["STUDENTDATATABLE"] != null)
            {
                StudentDataSet.StudentsDataTable StudentDataTable = (StudentDataSet.StudentsDataTable)Session["STUDENTDATATABLE"];
                if (string.IsNullOrEmpty(TbxSearchStudent.Text))
                {
                    GrdvStudents.DataSource = from student in StudentDataTable
                                              // As it is a strongly typed DataSet, the type (Class) of table is known at design time and,
                                              // all table columns are properties.
                                              select new
                    {
                        student.Id,
                        student.FirstName,
                        student.LastName,
                        studentEmail = GetStudentEmails(student.Id),                           // New property can be defined if additional information needs to be added as one more column programatically.
                    };

                    GrdvStudents.DataBind();
                }
                else
                {
                    GrdvStudents.DataSource = from student in StudentDataTable
                                              where student.FirstName.ToUpper().StartsWith(TbxSearchStudent.Text.ToUpper())
                                              // As it is a strongly typed DataSet, the type (Class) of table is known at design time and,
                                              // all table columns are properties.
                                              select new
                    {
                        student.Id,
                        student.FirstName,
                        student.LastName,
                        studentEmail = GetStudentEmails(student.Id),                           // New property can be defined if additional information needs to be added as one more column programatically.
                    };

                    GrdvStudents.DataBind();
                }
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StudentDataSetTableAdapters.StudentsTableAdapter studentsTableAdapter = new StudentDataSetTableAdapters.StudentsTableAdapter();
                StudentDataSet.StudentsDataTable studentsDataTable = new StudentDataSet.StudentsDataTable();
                studentsTableAdapter.Fill(studentsDataTable);

                Session["DATATABLE"] = studentsDataTable;

                // Using LINQ to select each row entry from student datatable, and mapping the filtered result to new object as defined by student datatable columns
                // This is strongly typed datatable
                gvStudents.DataSource = from student in studentsDataTable
                                        select new
                {
                    student.ID,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
                gvStudents.DataBind();
            }
        }
Ejemplo n.º 9
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            StudentDataSet.StudentsDataTable studentsDataTable = new StudentDataSet.StudentsDataTable();

            studentsDataTable = (StudentDataSet.StudentsDataTable)Session["DATATABLE"];
            if (!String.IsNullOrEmpty(txtTextToSearch.Text))
            {
                // Using LINQ to select each row entry from student datatable, filter entries based on string passed by user and mapping the filtered result to new object as defined by student datatable columns
                // This is strongly typed datatable
                gvStudents.DataSource = from student in studentsDataTable
                                        where student.Name.ToUpper().Contains(txtTextToSearch.Text.ToUpper())
                                        select new
                {
                    student.ID,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
            }
            else
            {
                Response.Write("<span style='font-weight:bold; color:red'>Please enter a text to search in the textbox.</span><br /><br />");

                // Using LINQ to select each row entry from student datatable, and mapping the filtered result to new object as defined by student datatable columns
                // This is strongly typed datatable
                gvStudents.DataSource = from student in studentsDataTable
                                        select new
                {
                    student.ID,
                    student.Name,
                    student.Gender,
                    student.TotalMarks
                };
            }
            gvStudents.DataBind();
        }