protected void BtnAdd_Click(object sender, EventArgs e)
    {
        //if (dt4.Rows.Count <= 0)
        //{
        foreach (GridViewRow gvrow in GridView1.Rows)
        {
            var textbox = gvrow.FindControl("txtmarks") as TextBox;

            if (textbox.Text != "")
            {
                m1 = Convert.ToInt32(textbox.Text);
                m2 = Convert.ToInt32(Session["Marks"]);
                if (m1 > m2)
                {
                    lblmsg.Text = "Vlues Should Not Breater Than The Total Marks";
                    //var lblID = gvrow.FindControl("Label1") as Label;
                    //i = obj.AddMarksObtained(Convert.ToInt32(ddnclass.SelectedValue), Convert.ToInt32(ddnsection.SelectedValue), Convert.ToInt32(ddnsub.SelectedValue), Convert.ToInt32(lblID.Text), Convert.ToInt32(Session["tuid"]), ddnexamtype.SelectedItem.Text, Convert.ToInt32(textbox.Text), Convert.ToInt32(Session["tuid"]), DateTime.Now.ToString());
                }
                if (m1 < m2)
                {
                    //lblmsg.Text = "Vlues Should Not Breater Than The Total Marks"
                    var lblID = gvrow.FindControl("Label1") as Label;
                    i = obj.AddMarksObtained(Convert.ToInt32(ddnclass.SelectedValue), Convert.ToInt32(ddnsection.SelectedValue), Convert.ToInt32(ddnsub.SelectedValue), Convert.ToInt32(lblID.Text), Convert.ToInt32(Session["tuid"]), ddnexamtype.SelectedItem.Text, Convert.ToInt32(textbox.Text), Convert.ToInt32(Session["tuid"]), DateTime.Now.ToString("dd/MM/yyyy"));
                }
            }
            if (textbox.Text == "")
            {
                var lblID = gvrow.FindControl("Label1") as Label;
                i = obj.AddMarksObtained(Convert.ToInt32(ddnclass.SelectedValue), Convert.ToInt32(ddnsection.SelectedValue), Convert.ToInt32(ddnsub.SelectedValue), Convert.ToInt32(lblID.Text), Convert.ToInt32(Session["tuid"]), ddnexamtype.SelectedItem.Text, Convert.ToInt32("00"), Convert.ToInt32(Session["tuid"]), DateTime.Now.ToString("dd/MM/yyyy"));
            }
        }
        BindData();
        Response.Redirect("MarksObtained.aspx");
        //}
    }