Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a requirement of binding two comboboxes----1)i have a table of columns stuid int pk_stuid,stuname varchar(50),address varchar(50)2) and 2nd table is age int FK_stu,class varchar(10),stuid int...now based on the selected item(stuid) in first combobox i have to display the age or class of that student in second combobox...i have succesfull to bind first combobox from backend but i cant to bind the second combobox based on the first... any answers....please suggest me
Posted

 
Share this answer
 
hey navin check out this. may this work for you.
C#
private void FillClass()
    {
        DataSet ds1 = ObjCand.GetddlClass(branchId, yearId);
        if (ds1.Tables[0].Rows.Count > 0)
        {
            GlobalSettings.FillDropDownList(ddlClass, ds1, "classid", "classname", "0", "All Class", "0");
        }
        else
        {
            GlobalSettings.FillDropDownList(ddlClass, ds1, "", "", "0", " All Class ", "0");
        }
        ddlDivision.Items.Insert(0, new ListItem("All Division", "0"));

    }

    private void FillDivision()
    {
        DataSet DS = objAlert.GetDiaryById(Convert.ToInt32(objEncryption.DecodeFrom64(Request.QueryString["cid"])));
        try
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                int intClassId = Convert.ToInt32(DS.Tables[0].Rows[0]["classid"]);
                DataSet ds1 = objAlert.GetAlertddlDivision(intClassId, yearId);
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    GlobalSettings.FillDropDownList(ddlDivision, ds1, "divisionid", "divisionname", "0", "All Division", "0");
                }
            }
        }
        catch (Exception ex)
        {

        }
    }

protected void ddlClass_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            DataSet ds1 = objAlert.GetAlertddlDivision(Convert.ToInt32(ddlClass.SelectedValue), yearId);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                GlobalSettings.FillDropDownList(ddlDivision, ds1, "divisionid", "divisionname", "0", "All Division", "0");
                MsgBox.Visible = false;
            }
            else
            {
                ddlDivision.Items.Clear();
                MsgBox.Visible = false;
                ddlDivision.Items.Insert(0, new ListItem("All Division", "0"));

            }

        }
        catch (Exception)
        {

            //  throw;
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900