protected void btnsarch_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable StuDT = StudentMst.GetAllActiveData();
                if (StuDT != null)
                {
                    DataTable Student_dt = StuDT.Select("DivId= " + drpdiv.SelectedValue).CopyToDataTable();

                    if (Student_dt != null && Student_dt.Rows.Count > 0)
                    {
                        GvStudent.DataSource = Student_dt;
                        GvStudent.DataBind();
                    }
                }
            }
            catch
            {
            }

            //else
            //{
            //    //MultiView1.ActiveViewIndex = -1;
            //}
        }
        protected void GvStudent_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            StudentMst.Delete(Convert.ToInt32(GvStudent.DataKeys[e.RowIndex].Value));
            DataTable StudentDT = StudentMst.GetAllActiveData();

            GvStudent.DataSource = StudentDT;
            GvStudent.DataBind();
        }
        protected void bindStudent()
        {
            DataTable dt = StudentMst.GetAllActiveData();

            if (dt != null && dt.Rows.Count > 0)
            {
                drpstudent.DataSource     = dt;
                drpstudent.DataTextField  = "rollno";
                drpstudent.DataValueField = "sid";
                drpstudent.DataBind();
                drpstudent.Items.Insert(0, "SELECT");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                DataTable StdDT = StdMst.GetAllActiveData();
                drpstd.DataSource     = StdDT;
                drpstd.DataTextField  = "StdName";
                drpstd.DataValueField = "Sid";
                drpstd.DataBind();

                drpstd.Items.Insert(0, "SELECT");
                drpstudent.Items.Insert(0, "SELECT");

                DataTable Student_dt = StudentMst.GetAllActiveData();
                GvStudent.DataSource = Student_dt;
                GvStudent.DataBind();
            }
        }
        protected void btnstuadd_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable studentDT = StudentMst.GetAllActiveData();

                if (string.IsNullOrEmpty(txtroll.Text))
                {
                    lblmsg.Text = "Roll can't be null !!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                    return;
                }

                if (string.IsNullOrEmpty(txtname.Text) || string.IsNullOrEmpty(txtemail.Text))
                {
                    lblmsg.Text = "Name and email can't be null !!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                    return;
                }

                if (string.IsNullOrEmpty(txtuname.Text) || string.IsNullOrEmpty(txtpass.Text))
                {
                    lblmsg.Text = "user name and and password can't be null !!";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                    return;
                }

                else
                {
                    DateTime   bdate  = Convert.ToDateTime(drpdd.SelectedItem.Text + " " + drpmm.SelectedItem.Text + " " + drpyyyy.SelectedItem.Text);
                    StudentMst stdobj = new StudentMst();
                    stdobj.Name = txtname.Text;
                    // stdobj.StdName = lblstd.Text;
                    // stdobj.DivName = drpdiv.SelectedItem.Text;
                    stdobj.DOB         = bdate.GetDateTimeFormats()[8].ToString();
                    stdobj.EDate       = DateTime.Now;
                    stdobj.Email       = txtemail.Text;
                    stdobj.Mobile      = txtmobi.Text;
                    stdobj.RollNo      = txtroll.Text;
                    stdobj.Pincode     = txtpin.Text;
                    stdobj.Uname       = txtuname.Text;
                    stdobj.Pass        = txtpass.Text;
                    stdobj.City        = txtcity.Text;
                    stdobj.MachineCode = txt_MachineId.Text != "" ? (int?)Convert.ToInt32(txt_MachineId.Text): null;
                    if (drpdiv.SelectedIndex > 0)
                    {
                        stdobj.DivName = drpdiv.SelectedItem.Text;
                        stdobj.DivId   = int.Parse(drpstd.SelectedValue);
                    }

                    if (drpstd.SelectedIndex > 0)
                    {
                        stdobj.StdName = drpdiv.SelectedItem.Text;
                        stdobj.StdId   = int.Parse(drpstd.SelectedValue);
                    }

                    if (!string.IsNullOrEmpty(FileUpload1.FileName))
                    {
                        FileUpload1.SaveAs(Server.MapPath("~/Studentimg/" + FileUpload1.FileName));
                        stdobj.Image = "~/Studentimg/" + FileUpload1.FileName;
                    }

                    if (StudentId != null)
                    {
                        stdobj.SID = int.Parse(StudentId.ToString());
                        if (stdobj.UpdateDataByKey())
                        {
                            lblmsg.Text = "Record updated Successfully";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                            resret();
                            Response.Redirect("StudentReport.aspx", false);
                        }
                    }
                    else
                    {
                        if (studentDT != null && studentDT.Rows.Count == 1)
                        {
                            lblmsg.Text = "UserName alredy exists !!";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                        }

                        stdobj.SID = StudentMst.GetNewSID();
                        stdobj.Insert();
                        lblmsg.Text = "Record Added Successfully";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
                        resret();
                    }
                }
            }
            catch (Exception ex)
            {
                lblmsg.Text = "Fail to Add record";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "fadeLabelOut()", true);
            }
        }