Wednesday, June 25, 2014

DropDownList

 <label>Advisor Compensation</label>
<asp:DropDownList CssClass="dropdown desiredPlanType" ID="ddlAdvisorCompensation" AppendDataBoundItems="true" runat="server" OnSelectedIndexChanged="ddlAdvisorCompensation_SelectedIndexChanged">
 <asp:ListItem Text="All" Value=""/> 
                        <%--<asp:ListItem Text="All" Value="All"></asp:ListItem>
                        <asp:ListItem Text="Fee-Based" Value="Fee-Based"></asp:ListItem>
                        <asp:ListItem Text="Commissioned  Based 25" Value="Commissioned  Based 25"></asp:ListItem>
                        <asp:ListItem Text="Commissioned  Based 50" Value="Commissioned  Based 50"></asp:ListItem>
                        <asp:ListItem Text="Commissioned  Based 100" Value="Commissioned  Based 100"></asp:ListItem>--%>
  </asp:DropDownList>


<%--<asp:RequiredFieldValidator ValidationGroup="Submit" ID="rfvProjectType" runat="server"
          ControlToValidate="ddlAdvisorCompensation" InitialValue="All" ErrorMessage="*"></asp:RequiredFieldValidator>--%>

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {            
                this.LoadAdvisorCompensation();
             }
         }


 private void LoadAdvisorCompensation()
        {
            InvestmentBO investmentBO = new InvestmentBO();
            if (investmentBO.GetAdvisorCompensation().Count() > 0)
            {
                ddlAdvisorCompensation.Items.Clear();
                ddlAdvisorCompensation.DataSource = investmentBO.GetAdvisorCompensation();
                ddlAdvisorCompensation.DataValueField = "AdvisorCompensation";
                ddlAdvisorCompensation.DataTextField = "AdvisorCompensation";
                ddlAdvisorCompensation.Items.Add("All");
                ddlAdvisorCompensation.DataBind();
            }
        }

private void FillDropdownList()
        {
            ddlAdvisorCompensation.SelectedValue = Request.QueryString["AdvisorCompensation"];        
        }

public List<InvestmentGroup> GetAdvisorCompensation()
        {
            using (var _dbCon = new FiduciaryKEntities())
            {              
var acAll = from ac in _dbCon.Database.SqlQuery<InvestmentGroup>(SQLConstants.AdvisorCompensation)
               select ac;
                return acAll.ToList();
            }
        }

 public class InvestmentGroup
    {      
        public string AdvisorCompensation { get; set; }
    }

 public static class SQLConstants
    {        
        public static string AdvisorCompensation = "SELECT distinct AdvisorCompensation FROM vw_FiduciaryK_GetInvestmentGroupName where AdvisorCompensation !='null'";
    }


No comments:

Post a Comment