从数据库中检索值并显示在下拉列表中。 [英] retrieve value from database and display in dropdownlist.

查看:83
本文介绍了从数据库中检索值并显示在下拉列表中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨先生;



我希望当我点击搜索按钮时,会在组合框中显示或设置值。从数据库中检索的值?

请解决我的问题...



提前谢谢...

hi sir;

i want that when i click the search button the value are display or set in combo box. The values retrieved from database?
please solve my problem...

Thanks in advance...

推荐答案

首先你可以尝试自己,在哪一行,你面对的问题只是直接问你那条线,你问代码意味着'对你不好。



任何人都可以提供任何你想要的代码,但你无法理解这种逻辑。



这里我要做的是我有一个文本框,我输入一些文字,然后点击搜索按钮然后根据搜索结果显示在DDL上。



您编写SQL查询

first of all you can try by your self , in which line your facing problem just ask that line alone directly you ask code means that''s not good for you.

Any one give a code whatever you expect but you can''t understand that logic .

Here what i''m trying to do is i have a textbox in that i enter some text and then click on search button then based upon the search the result to be displayed on DDL.

You write your SQL query
SELECT COL1,COL2,COL3 FROM TABLE1 WHERE COL1 LIKE '%searchedresult%'




 protected void btnSearch_OnClick(object sender, EventArgs e)
    {
        Bind_Projects();
    }

protected void Bind_Projects()
    {
        string Search = txtSearch.Text.Trim();
        DataSet dsProj = //what do you want you fetch taht information                           
        ddlSearch.DataSource = dsProj;
        ddlSearch.DataTextField = "Proj_Description";
        ddlSearch.DataValueField = "Proj_Code";
        ddlSearch.DataBind();
        ddlSearch.Items.Insert(0, "---Select---");
    }


这篇关于从数据库中检索值并显示在下拉列表中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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