protected void Load_MonthsAndRules_ForRank(int RankID) { try { string EID = ddlEvaluations.SelectedValue; DataTable dtMonths = BLL_Crew_Evaluation.Get_EvaluationMonths(int.Parse(EID), RankID); DataTable dtRules = BLL_Crew_Evaluation.Get_EvaluationRules(int.Parse(EID), RankID); foreach (ListItem li in lstSelectedMonth.Items) { li.Selected = false; } foreach (ListItem li in lstSelectedRules.Items) { li.Selected = false; } foreach (DataRow dr in dtMonths.Rows) { foreach (ListItem li in lstSelectedMonth.Items) { if (li.Value == dr["monthno"].ToString() && dr["active_status"].ToString() == "1") { li.Selected = true; } } //lstSelectedMonth.Items[int.Parse(dr["monthno"].ToString()) - 1].Selected = dr["active_status"].ToString() == "1" ? true : false; } foreach (DataRow dr in dtRules.Rows) { foreach (ListItem li in lstSelectedRules.Items) { if (li.Value == dr["RuleID"].ToString() && dr["active_status"].ToString() == "1") { li.Selected = true; } } //lstSelectedRules.Items[int.Parse(dr["RuleID"].ToString()) - 1].Selected = dr["active_status"].ToString() == "1" ? true : false; } } catch { } }