城市的下拉列表 [英] dropdownlist for city , satate

查看:57
本文介绍了城市的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有3个针对国家,州,城市的下拉列表
选择国家,州drpdwn列表应自动绑定.通过选择州,城市下拉列表应绑定
请尽快帮助我
谢谢

i have 3 dropdownlist in my page for country,state,city
selecting country, state drpdwn list should automatically will bind.and as that by selecting state,city dropdown list should be binded
please help me out soon
thank you

推荐答案

订阅DDL.SelectedIndexChanged事件并在回发中填充下一个DDL.

您可以将其包装在UpdatePanel中,以使其部分刷新.
Subscribe to the DDL.SelectedIndexChanged event and populate the next DDL in the postback.

You could wrap this in an UpdatePanel to make it a partial page refresh.


请参阅以下链接....

http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists- in-ASP.Net.aspx [ ^ ]
Refer Following Links....

http://www.aspsnippets.com/Articles/Creating-Cascading-DropDownLists-in-ASP.Net.aspx[^]


在选定的索引更改事件发生时应绑定数据.

You should bind your data when the selected index change event.

protected void dlstcountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        string messg = "";
        DataTable dtstate = new DataTable();

       
      sql = "Select State from Tablename where Country='"+dlstcountry.SelectedValue.Trim()+ "'";
        dtstate = GetRecord(sql, ref messg);
        dlststate .Items.Clear();
        if (dtstate .Rows.Count != 0)
        {
            for (int i = 0; i < dtstate .Rows.Count; i++)
            {
                dlststate.Items.Add(new ListItem(dtstate .Rows[i][0].ToString()));
            }
        }

    }




希望有帮助,
Theingi Win




Hope Be helpful,
Theingi Win


这篇关于城市的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆