将列表框更改为RadComboBox搜索功能无效 [英] changed listbox to RadComboBox search feature not working

查看:66
本文介绍了将列表框更改为RadComboBox搜索功能无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用telerik下拉:RadComboBox。我正在使用asp listbox来下载porpose,但是为了要求我要将列表框下拉到telerik:RadComboBox。下拉工作正常,但是在我将列表框更改为telerik后,从下拉列表中选择值的搜索功能无效:RadComboBox。

I've a drop down for which I am using telerik:RadComboBox. I was using asp listbox for the drop down porpose, but for requirement I've to change the listbox drop down to telerik:RadComboBox. The drop down is working fine but the search feature selecting the value from the drop down is not working after I changed the listbox to telerik:RadComboBox.

////// CountrySearch.aspx page
<tr>
<td class="tbl_label">
Country Code:
</td>
<td>
<telerik:RadComboBox ID="ddlCountryCode" runat="server" markfirstmatch="True" Rows="1"></telerik:RadComboBox>

<%--   <asp:ListBox ID="ddlCountryCode" runat="server" Rows="1"></asp:ListBox>  --%>
</td>
</tr>
<tr>
<td class="tbl_label">
Country:
</td>
<td>

<asp:TextBox ID="findCountryFilter" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search"

CausesValidation="False" />
</td>
</tr>

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SearchDataSet"

TypeName="clsCountry" OldValuesParameterFormatString="original_{0}">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCountryCode" Name="CountryCode" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="findCountryFilter" Name="searchValue" PropertyName="Text"

Type="String" />
</SelectParameters>
</asp:ObjectDataSource>







////// CountrySearch.aspx page.cs
public void addCountry()
    {
        try
        {
            ddlCountryCode.Items.Clear();
            nSQLWrapper nswCountry = new nSQLWrapper();
            string strQuery = "SELECT Country_cd,Country_name  FROM Country order by Country_name";
            SqlDataReader dr = nswCountry.select(strQuery);
            //ddlCountryCode.Items.Add(new ListItem("--- SELECT ---", ""));
            ddlCountryCode.Items.Add(new RadComboBoxItem("--- SELECT ---", ""));
            if (dr.HasRows == true)
            {
                while (dr.Read())
                {
                    //ddlCountryCode.Items.Add(new ListItem(dr["Country_name"].ToString().Trim(), dr["Country_cd"].ToString().Trim()));
                    ddlCountryCode.Items.Add(new RadComboBoxItem(dr["Country_name"].ToString().Trim(), dr["Country_cd"].ToString().Trim()));
                }
            }
            dr.Close();
        }
        catch (Exception) { }
    }
/////////// clsCountry

public DataSet SearchDataSet(String CountryCode, String searchValue)
    {
        try
        {
            if (!String.IsNullOrEmpty(CountryCode))
            {
                DBObjWrapperReport nqw = new DBObjWrapperReport();
                string strQuery = "SELECT ind.industry_cd,ind.industry_name,ind.industry_address, ind.industry_output,c.Country_name," +
                "FROM industry_indanch ind " +
                "INNER JOIN country c ON c.Country_number = ind.cntry_number AND ind.bank_cd = '" + CountryCode + "'";
                
                nqw.SelectString = strQuery;
                DataTable dt = new DataTable();
                DataSet ds = new DataSet();
                dt = nqw.GetTable();
                if (dt != null)
                {
                    ds.Tables.Add(dt);
                    return ds;
                }
                else
                    return null;
            }
            else
                return null;
        }
        catch (Exception) { return null; }
    }
}

推荐答案

对于RadComboBox,您需要将ObjectDataSource Id设置为



For the RadComboBox you need to set the ObjectDataSource Id as

DataSourceID="ObjectDataSource1"





你必须提到RadComboBox的文本字段和值字段为





And you have to mention the Text Field and Value Field for the RadComboBox as

DataTextField="Title" DataValueField="Id"





进行上述更改,看看是否有效。



另请参阅下面的演示链接



RadComboBox ObjectDataSource [ ^ ]



如果没有帮助,请随时评论并粘贴完整的代码。



Make the above changes and see if it works.

And also refer the Demo link below

RadComboBox ObjectDataSource[^]

If it doesn't help please feel free to comment and also paste your full code.


这篇关于将列表框更改为RadComboBox搜索功能无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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