protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { int ruleID = Request.QueryString["id"] == null ? 0 : Int32.Parse(Request.QueryString["id"]); if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Get questionID here int ruleQuesID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ruleQuesId")); int questionTypeID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ruleQuesTypeID")); HiddenField questionIDHidden = (HiddenField)e.Item.FindControl("ruleQuestionIDHidden"); HiddenField ruleQuestionTypeIDHiddenBackend = (HiddenField)e.Item.FindControl("ruleQuestionTypeIDHidden"); ruleQuestionTypeIDHiddenBackend.Value = questionTypeID.ToString(); questionIDHidden.Value = ruleQuesID.ToString(); if (questionTypeID == 1101) { RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("radlstPubs"); Panel queryPanelOneBackend = (Panel)e.Item.FindControl("queryPanelOne"); queryPanelOneBackend.Visible = false; ImpDao impDaoObj = new ImpDao(); List <ImpRuleQuesAnswer> answerList = impDaoObj.getRuleAnswerList(ruleQuesID, questionTypeID); RadioButtonList1.DataSource = answerList; RadioButtonList1.DataTextField = "answerStatemet"; RadioButtonList1.DataValueField = "answerId"; RadioButtonList1.DataBind(); if (ruleID != 0) { ImpRuleQuesAnswer ruleAns = impDaoObj.getRuleAnswerByRuleIDQuestionID(ruleQuesID, ruleID); RadioButtonList1.SelectedValue = ruleAns.answerId.ToString(); } } else if (questionTypeID == 1102) { RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("radlstPubs"); DBUtils dbUtils1 = new DBUtils(); SqlDataReader attributeTypeReader1 = dbUtils1.readOperation("SELECT * FROM App_CODE Where CODE_TYPE_ID=1600"); while (attributeTypeReader1.Read()) { RadioButtonList1.Items.Add(new ListItem(attributeTypeReader1["CODE_VALUE"].ToString(), attributeTypeReader1["CODE_ID"].ToString())); } dbUtils1.closeDBConnection(); if (ruleID != 0) { ImpDao impDaoObj = new ImpDao(); ImpRuleQuesAnswer ruleAns = impDaoObj.getRuleDBValueByRuleIDQuestionID(ruleQuesID, ruleID); RadioButtonList1.SelectedValue = ruleAns.comparisonTypeID.ToString(); TextBox comparisonValueTxtBox = (TextBox)e.Item.FindControl("dbQueryValue"); comparisonValueTxtBox.Text = ruleAns.comparisonValue.ToString(); } } } }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { String questionJSON = Request.QueryString["dbQueryValues"]; List <ImpRuleQuestion> listOfQuestionValues = new List <ImpRuleQuestion>(); if (questionJSON != "]") { listOfQuestionValues = JsonConvert.DeserializeObject <List <ImpRuleQuestion> >(questionJSON); } if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Get questionID here int ruleQuesID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ruleQuesId")); int questionTypeID = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ruleQuesTypeID")); RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("radlstPubs"); HiddenField HiddenFieldQuesType = (HiddenField)e.Item.FindControl("hiddenQuesType"); HiddenFieldQuesType.Value = questionTypeID.ToString(); HiddenField HiddenFieldQuesID = (HiddenField)e.Item.FindControl("hiddenQuesID"); HiddenFieldQuesID.Value = ruleQuesID.ToString(); if (questionTypeID == 1101) { ImpDao impDaoObj = new ImpDao(); List <ImpRuleQuesAnswer> answerList = impDaoObj.getRuleAnswerList(ruleQuesID, questionTypeID); RadioButtonList1.DataSource = answerList; RadioButtonList1.DataTextField = "answerStatemet"; RadioButtonList1.DataValueField = "answerId"; RadioButtonList1.DataBind(); } else if (questionTypeID == 1102) { String calculatedValue = ""; foreach (ImpRuleQuestion quesInner in listOfQuestionValues) { if (quesInner.ruleQuesId == ruleQuesID) { calculatedValue = quesInner.dbQueryCalculatedValue.ToString(); } } HiddenField HiddenFieldCalculatedValue = (HiddenField)e.Item.FindControl("HiddenCalculatedValue"); HiddenFieldCalculatedValue.Value = calculatedValue.ToString(); DBUtils dbUtils1 = new DBUtils(); SqlDataReader attributeTypeReader1 = dbUtils1.readOperation("SELECT * FROM App_CODE Where CODE_TYPE_ID=1600"); while (attributeTypeReader1.Read()) { RadioButtonList1.Items.Add(new ListItem(attributeTypeReader1["CODE_VALUE"].ToString() + " = " + calculatedValue, attributeTypeReader1["CODE_ID"].ToString())); } dbUtils1.closeDBConnection(); } } }