public void Save(List <AnsweredQuestion> lst) { qaRepos.Save(lst); }
protected void btnSave_clicked(object sender, System.EventArgs e) { List <AnsweredQuestion> ansLst = new List <AnsweredQuestion>(); foreach (RepeaterItem item in repSurvey.Items) { Panel pnl = item.FindControl("pnlAnswer") as Panel; CheckBoxList chkLst = item.FindControl("chkLstAnswer") as CheckBoxList; RadioButtonList rdoLst = item.FindControl("rdoLstAnswer") as RadioButtonList; Repeater rep = item.FindControl("rep") as Repeater; string questionType = pnl.Attributes["QuestionType"].ToString(); int qid = Int32.Parse(pnl.Attributes["QuestionID"].ToString()); List <int> ansIDLst = new List <int>(); if (questionType.ToLower() == "RadioButton".ToLower()) { foreach (ListItem li in rdoLst.Items) { if (li.Selected) { AnsweredQuestion ansQ = new AnsweredQuestion(); ansQ.UserID = UserHelper.GetLoggedInUser(HttpContext.Current.Session).UserID; ansQ.QID = qid; ansQ.AID = Int32.Parse(li.Value); ansLst.Add(ansQ); } } } else if (questionType.ToLower() == "CheckBox".ToLower()) { foreach (ListItem li in chkLst.Items) { if (li.Selected) { AnsweredQuestion ansQ = new AnsweredQuestion(); ansQ.UserID = UserHelper.GetLoggedInUser(HttpContext.Current.Session).UserID; ansQ.QID = qid; ansQ.AID = Int32.Parse(li.Value); ansLst.Add(ansQ); } } } else { foreach (RepeaterItem repItem in rep.Items) { DropDownList dd = repItem.FindControl("ddRating") as DropDownList; if (dd.SelectedIndex > 0) { AnsweredQuestion ansQ = new AnsweredQuestion(); ansQ.UserID = UserHelper.GetLoggedInUser(HttpContext.Current.Session).UserID; ansQ.QID = qid; ansQ.AID = Int32.Parse(dd.Attributes["AID"].ToString()); ansQ.Answer = dd.SelectedValue; ansLst.Add(ansQ); } } } } quesRepos.ClearAnswers(UserHelper.GetLoggedInUser(HttpContext.Current.Session).UserID, screenID); //clear all answers first quesRepos.Save(ansLst); //save answers }