过滤记录并用巨大的SQL数据填写下拉列表 [英] Filter records and fill in drop down with huge sql data

查看:58
本文介绍了过滤记录并用巨大的SQL数据填写下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有超过500000条记录的数据我想搜索数据并填写其他下拉列表

i我使用ListSearchExtender下拉其工作但它是非常慢



当我搜索并选择第一个下拉列表时,它应该填写另一个下拉列表

当我搜索并选择第二个下拉列表时它应该填充第一个下拉..



有没有其他方法来过滤数据并填写????????????????



这是我的代码



Hi
I have a data of more that 500000 records i want to search data and fill in other dropdown list
i am using ListSearchExtender with dropdown its working buts it is very slow

when i search and select first dropdown it should fill another dropdown
and when i search and select second dropdown it should fill frst dropdown..

is there any alternative way to filter data and fill ??????????????

here is my code

<td class="style43" colspan="3">
                            <asp:DropDownList ID="ddlICD10" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"

  > </asp:DropDownList>
                            <asp:ListSearchExtender ID="ddlICD10_ListSearchExtender" runat="server"  Enabled="True" TargetControlID="ddlICD10">   </asp:ListSearchExtender>
                           ICD10 DESCRIPTION :<asp:DropDownList ID="ddlDesc" runat="server"

                       AutoPostBack="True" Height="22px"

                                onselectedindexchanged="DropDownList2_SelectedIndexChanged" Width="319px"></asp:DropDownList>
 <asp:ListSearchExtender ID="ddlDesc_ListSearchExtender" runat="server"

    Enabled="True" TargetControlID="ddlDesc">       </asp:ListSearchExtender>





这里是c#代码





here is c# code

protected void Page_Load(object sender, EventArgs e)
    {
       
                GetDDCode();

}
      protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        con.Open();
        //DataTable dt = new DataTable();
        //dt = ds.Tables[0];
        //DataRow newrow = dt.NewRow();
        //newrow = ds.Tables.
        string sql = "select Description from ICD10 where ICD10code = '" + ddlICD10.Text + "'";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.CommandType = CommandType.Text;
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            ddlDesc.Text = dr["Description"].ToString();
        }
    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        con.Open();
        string sql = "select ICD10code from ICD10 where Description = '" + ddlDesc.Text + "'";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.CommandType = CommandType.Text;
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            ddlICD10.Text = dr["ICD10code"].ToString();
        }
    }

    public void GetDDCode()
    {
        con.Open();
        string sql = "select ICD10code,Description from ICD10";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter adp = new SqlDataAdapter();
      
        adp.SelectCommand = cmd;
        adp.Fill(ds);
        ddlICD10.DataTextField = "ICD10code";
        ddlICD10.DataValueField = "ICD10code";
        ddlICD10.DataSource = ds;
        ddlICD10.DataBind();
        ddlDesc.DataTextField = "Description";
        ddlDesc.DataValueField = "Description";
        ddlDesc.DataSource = ds;
        ddlDesc.DataBind();
        con.Close();
    }

推荐答案

对于大量数据,我认为你不应该直接将所有数据填入下拉列表。而不是你的方式,你应该使用Ajax / Jquery和webservices来做到这一点。



- 创建一个web服务来从你的数据库中获取数据。

- 搜索数据时使用自动填充功能。
With huge data, I think you shouldn't fill all of them to dropdownlist directly. Instead of your way, you should use Ajax/Jquery & webservices to do that.

- Create a webservice to get the data from your db.
- Use autocomplete when searching your data.


这篇关于过滤记录并用巨大的SQL数据填写下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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