protected void Button1_Click(object sender, EventArgs e) { int ID_Question = int.Parse(hiddenIDQ.Value); int ID_Student=int.Parse(Request.QueryString["ID_Student"]); DataTable dt = new tbl_TestResultDetailTableAdapter().GetDataByID_Student_ID_Question(ID_Student, ID_Question); if (dt.Rows.Count > 0) { new tbl_TestResultDetailTableAdapter().UpdateScoreStudent( double.Parse(TextBox1.Text),ID_Student, ID_Question); } else { new tbl_TestResultDetailTableAdapter().Insert(ID_Student, ID_Question, "", double.Parse(TextBox1.Text)); } FillGrid(); Cancel(); Label1.Text = "نمره به درستی ثبت گردید"; Label1.Visible = true; }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex != -1) { int ID_Student=int.Parse(Request.QueryString["ID_Student"]); int ID_Question=int.Parse( ((Label)(e.Row.FindControl("lblID"))).Text); DataTable dt = new tbl_TestResultDetailTableAdapter().GetDataByID_Student_ID_Question(ID_Student, ID_Question); if (dt.Rows.Count > 0) { ((Label)(e.Row.FindControl("lbl_MarkStudent"))).Text=dt.Rows[0]["trd_Score"].ToString(); ((HiddenField)(e.Row.FindControl("hiddenAnswerStudent"))).Value = dt.Rows[0]["trd_result"].ToString(); ((HiddenField)(e.Row.FindControl("hiddenScore"))).Value = dt.Rows[0]["trd_Score"].ToString(); } else { ((Label)(e.Row.FindControl("lbl_MarkStudent"))).Text = ""; ((HiddenField)(e.Row.FindControl("hiddenAnswerStudent"))).Value = ""; ((HiddenField)(e.Row.FindControl("hiddenScore"))).Value = ""; } } }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex != -1) { int ID_Question = int.Parse(((Label)(e.Row.FindControl("lblID"))).Text); int ID_Student = int.Parse(Request.Cookies["ID_Role"].Value); DataTable dt=new tbl_TestResultDetailTableAdapter().GetDataByID_Student_ID_Question(ID_Student, ID_Question); if (dt.Rows.Count == 0) { ((CheckBox)(e.Row.FindControl("CheckBox1"))).Checked = false; } else { ((HiddenField)(e.Row.FindControl("hiddenAnswer"))).Value= dt.Rows[0]["trd_Result"].ToString(); ((CheckBox)(e.Row.FindControl("CheckBox1"))).Checked = true; } } }