You must Sign In to post a response.
  • Category: JavaScript

    I have four regions (i.e asia,europe,middle-east,america)

    Hi,

    i have four regions (i.e asia,europe,middle-east,america) i have place it drop-down list when i select asia it has to display for example say like india,china,japan but i am unable to fetch the all three values but iam getting only one values for that drop-down when i select one region can any one explain about the query with any sample example
  • #754214
    Hi,

    inside page load . u call dropdownlist() like:
    and check ispostbackprop of this page, then only its disply u all three records...

    protected void page_load()
    {
    if(!ispostback)
    {
    loadcountry();
    }
    }



    Hope its help u out..



    thanks,
    chitaranjan

  • #754216
    hi thanks for the example.

  • #754220
    Hi,

    You can use below code;


    protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
    ddlState.DataSource = res.States(Convert.ToInt16(ddlCountry.SelectedValue));
    ddlState.DataTextField = "StateName";
    ddlState.DataValueField = "StateID";
    ddlState.DataBind();
    ddlState.Items.Insert(0, "Select");
    ddlDist.Enabled = false;
    ddlCity.Enabled = false;
    }
    protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)

    {
    ddlDist.DataSource = res.Districts(Convert.ToInt16(ddlState.SelectedValue));
    ddlDist.DataTextField = "DistName";
    ddlDist.DataValueField = "DistID";
    ddlDist.DataBind();
    ddlDist.Items.Insert(0, "Select");
    ddlDist.Enabled = true;
    ddlCity.Enabled = false;
    }


    For complete article, read www.pyarb.com/2012/08/populate-dropdownlist-dynamically-in-asp-net-country-state-district-city.html

    All the Best.

    -------------
    Glad to be,
    John Bhatt
    Editor - DNS Forums
    https://www.pyarb.com

  • #754239
    Hi,

    Based on region selection if you want to show countries list then refer below sample.


    protected void Page_Load(object sender, EventArgs e)
    {
    If(!IsPostBack)
    {
    Bind_Region();
    Bind_Countries();
    }
    }
    protected void Bind_Region()
    {
    ddlRegion.DataSource=//get regions list from database.
    ddlRegion.DataTextField="Region_Name";
    ddlRegion.DataValueField="Region_Id";
    ddlRegion.DataBind();
    }
    protected void Bind_Countries()
    {
    ddlCtry.DataSource=obj.Get_Countries(ddlRegion.SelectedValue);
    //here Get_Countries is the business logic implementation, you should implement your business logic on here.

    ddlCtry.DataTextField="Ctry_Name";
    ddlCtry.DataValueField="Ctry_Id";
    ddlCtry.DataBind();
    }

    protected void ddlRegion_OnSelectedIndexChanged(object sender, EventArgs e)

    {
    Bind_Countries();
    }


    Try something like above to achieve your goal..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments