pls help me.... its vry urgnt.... i can't edit the exam names whn i click the submit button... pls help me frnds .... below ones r ma codings
_______________________________________________________________________________________________________________________
| ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||
| onclick="btnSubmit_Click" /> | ||||||||||||||||||||||||||||||
__________________________________________________________________________________________________________________________
public partial class EditExam : BasePage
{
ExaminationBl bl = new ExaminationBl();
LookUpBl blLookup = new LookUpBl();
StudentBl studBl=new StudentBl();
int courseId=0;
private void PopulateSemesters()
{
courseId = Convert.ToInt32(ddlCourse.SelectedValue);
hdnCurriculamId.Value = Convert.ToString(bl.GetCurriculamId(courseId));
if(courseId > 0 ) Utils.UIHelper.LoadDropDownList(ref ddlYearSemester, blLookup.GetCourseSemestersLookups(courseId));
}
private void InitPageObjects()
{
UIHelper.LoadDropDownList(ref ddlCourse, blLookup.GetCourseLookups());
PopulateSemesters();
if (Request.QueryString["Id"] != null)
{
int Id = Convert.ToInt32(Request.QueryString["Id"].ToString());
if (Id > 0)
{
Examination exam = bl.GetExamDeatils(Id);
this.SetDataObjects(exam);
btnReset.Text = "Back";
btnReset.PostBackUrl = "ListExam.aspx";
}
}
else
{
btnReset.Attributes.Add("onclick", "return ClealFields();");
}
}
private void SetDataObjects(Examination exam)
{
hdnExamId.Value = exam.ID.ToString();
hdnCurriculamId.Value = exam.CurriculamId.ToString();
txtExamCode.Text = exam.Code;
txtExamName.Text = exam.Name;
int courseId = exam.Course.Id;
int batchID = exam.Batch.Id;
Utils.UIHelper.LoadDropDownList(ref ddlbatch, blLookup.GetBatchLookups(courseId));
Utils.UIHelper.LoadDropDownList(ref ddlYearSemester, blLookup.GetCourseSemestersLookups(courseId));
Utils.UIHelper.SelectDropDownListItem(ref ddlCourse, courseId.ToString());
Utils.UIHelper.SelectDropDownListItem(ref ddlbatch, batchID.ToString());
Utils.UIHelper.SelectDropDownListItem(ref ddlYearSemester, exam.YearSequence.ToString());
PopulateExamPapers(exam.Papers);
}
private void Page_Init(object sender, System.EventArgs e)
{
masterPage = (SecurePage)Page.Master;
masterPage.SetPageTitle("Examinations Entry/Update", "Create Update Examinations.");
if (!Page.IsPostBack)
{
masterPage.PopulateSubMenu(5);
this.InitPageObjects();
}
}
private void PopulateExamPapers(ExamPapers list)
{
rptrPapers.DataSource = list;
rptrPapers.DataBind();
}
private ExamPapers GetExamPapers(bool bDelete = false)
{
//List list = new List();
ExamPapers list = new ExamPapers();
foreach (RepeaterItem rptItem in rptrPapers.Items)
{
ExamPaper item = new ExamPaper();
HiddenField hdnPaperId = rptItem.FindControl("hdnPaperId") as HiddenField;
Label lblPaperName = rptItem.FindControl("lblPaperName") as Label;
CheckBox chkPaper = rptItem.FindControl("chkPaper") as CheckBox;
TextBox txtDate = rptItem.FindControl("txtDate") as TextBox;
TextBox txtExtMaxMark = rptItem.FindControl("txtExtMaxMark") as TextBox;
TextBox txtExtPassMark = rptItem.FindControl("txtExtPassMark") as TextBox;
TextBox txtIntMaxMark = rptItem.FindControl("txtIntMaxMark") as TextBox; ///Edited by pritam
TextBox txtIntPassMark = rptItem.FindControl("txtIntPassMark") as TextBox;
TextBox txtExamDuration = rptItem.FindControl("txtExamDuration") as TextBox; ///Edited by pritam
if (bDelete && chkPaper.Checked) continue; // skip adding the row
item.ExamDate = Convert.ToDateTime(txtDate.Text);
item.ExtMaximumMark = Convert.ToDecimal(txtExtMaxMark.Text);
item.ExtPassMark = Convert.ToDecimal(txtExtPassMark.Text);
item.InternalMaxMark = Convert.ToDecimal(txtIntMaxMark.Text);
item.InternalPassMark = Convert.ToDecimal(txtIntPassMark.Text);
item.TotalMaxMark = Convert.ToDecimal(item.ExtMaximumMark + item.InternalMaxMark);
item.TotalPassMark = Convert.ToDecimal(item.ExtPassMark + item.InternalPassMark);
item.ExamDuration = txtExamDuration.Text; ////Edited by pritam
item.Paper = new LookUp();
item.Paper.Id = Convert.ToInt32(hdnPaperId.Value);
item.Paper.Name = lblPaperName.Text;
list.Add(item);
}
return list;
}
protected void rptrPapers_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ExamPaper item = e.Item.DataItem as ExamPaper;
HiddenField hdnPaperId = e.Item.FindControl("hdnPaperId") as HiddenField;
Label lblPaperName = e.Item.FindControl("lblPaperName") as Label;
CheckBox chkPaper = e.Item.FindControl("chkPaper") as CheckBox;
TextBox txtDate = e.Item.FindControl("txtDate") as TextBox;
TextBox txtExtMaxMark = e.Item.FindControl("txtExtMaxMark") as TextBox;
TextBox txtExtPassMark = e.Item.FindControl("txtExtPassMark") as TextBox;
TextBox txtIntMaxMark = e.Item.FindControl("txtIntMaxMark") as TextBox;
TextBox txtIntPassMark = e.Item.FindControl("txtIntPassMark") as TextBox;
TextBox txtExamDuration = e.Item.FindControl("txtExamDuration") as TextBox; ////Edited by pritam
txtDate.Text = item.ExamDate.ToShortDateString();
txtExtMaxMark.Text = item.ExtMaximumMark.ToString();
txtExtPassMark.Text = item.ExtPassMark.ToString();
txtIntMaxMark.Text = item.InternalMaxMark.ToString();
txtIntPassMark.Text = item.InternalPassMark.ToString();
txtExamDuration.Text = item.ExamDuration.ToString(); ////Edited by pritam
hdnPaperId.Value = item.Paper.Id.ToString();
lblPaperName.Text = item.Paper.Name;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void lnkRemovePaper_Click(object sender, EventArgs e)
{
ExamPapers list = this.GetExamPapers(true);
PopulateExamPapers(list);
}
private Examination GetDataObjects()
{
Examination exam = new Examination();
// exam.Papers = new ExamPapers(); ///Edited by pritam
exam.Id = Convert.ToInt32(hdnExamId.Value);
exam.ID = exam.Id;
exam.Code = txtExamCode.Text;
exam.Name = txtExamName.Text;
exam.CurriculamId = Convert.ToInt32(hdnCurriculamId.Value);
exam.CurriculumID = exam.CurriculamId;
exam.Course = new LookUp();
exam.Course.Id = Convert.ToInt32(ddlCourse.SelectedValue);
exam.Batch = new LookUp();
exam.Batch.Id = Convert.ToInt32(ddlbatch.SelectedValue);
exam.YearSequence = Convert.ToInt32(ddlYearSemester.SelectedValue);
exam.Papers = this.GetExamPapers();
return exam;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
if (ddlbatch.SelectedIndex > 0)
{
Examination item = this.GetDataObjects();
int Id = bl.SavExamDeatils(item);
if (Id > 0)
{
Response.Redirect("ViewExam.aspx?Id=" + Id.ToString()); ////Id.ToString());
}
}
else
{
masterPage.SetMessage("Please select a Batch from the Dropdown List to proceed.");
}
}
catch (Exception ex)
{
masterPage.SetMessage(ex.Message);
}
}
protected void btnRetrivePapers_Click(object sender, EventArgs e)
{
int courseId = Convert.ToInt32(ddlCourse.SelectedValue);
int yearId = Convert.ToInt32(ddlYearSemester.SelectedValue);
if (courseId > 0) PopulateExamPapers(bl.GetExamPapers(courseId, yearId));
}
protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlCourse.SelectedIndex > 0)
{
courseId = Convert.ToInt32(ddlCourse.SelectedValue);
//this.PopulateSemesters();
Utils.UIHelper.LoadDropDownList(ref ddlbatch, blLookup.GetBatchLookups(courseId));
Utils.UIHelper.LoadDropDownList(ref ddlYearSemester, blLookup.GetCourseSemestersLookups(courseId));
}
else
{
masterPage.SetMessage("Please select a Course from the Dropdown List to proceed.");
}
}
}
}
.....................................................................................................................................................................................................................................................
Replies
Know the answer? Post it — somebody with the same question will find it here.