Sunday, March 9, 2014

Dynamically Generate Multiple CheckBox and send all checked checkbox Ids as a string to server...

 <p><asp:CheckBoxList ID="lstFundGroup" runat="server">
    </asp:CheckBoxList></p>

 private void LoadInvestmentGroupName(int id)
        {
             investmentBO = new InvestmentBO();          
            lstFundGroup.DataTextField = "GroupName";
            lstFundGroup.DataValueField = "GroupID";
            lstFundGroup.DataSource = investmentBO.GetInvestmentGroupName(id);
            lstFundGroup.DataBind();
        }
 protected void btnSearchFunGruop_Click(object sender, EventArgs e)
        {
            int i;
            string idFundGroup ="";
            for (i = 0; i < lstFundGroup.Items.Count; i++)
            {
                if (lstFundGroup.Items[i].Selected)
                {
                    idFundGroup = idFundGroup + lstFundGroup.Items[i].Value.ToString() + ",";
                }
            }
            idFundGroup = idFundGroup.Substring(0, idFundGroup.Length - 1);
        }

No comments:

Post a Comment