我在我的应用程序中使用radsearchbox。数据源正在工作并显示下拉列表中的值,但是当我在下拉列表中选择一个项目时,文本框不会填充。我的代码是
<telerik:RadSearchBox ID="RadSearchBox1" runat="server"
Filter="StartsWith" EnableAutoComplete="true" DataTextField="Name">
</telerik:RadSearchBox>
并在代码中
string comtext = "select Name from tblcustomer";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
SqlCommand cmd = new SqlCommand(comtext, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
RadSearchBox1.DataSource = ds;
RadSearchBox1.DataBind();
答案 0 :(得分:1)
您的问题可能是您没有使用SearchContext
。但我认为您只需要为搜索框指定关键字段。请注意,参数DataValueField
指向表格的ID。 (更改为您的特定表ID字段)
<telerik:RadSearchBox ID="RadSearchBox1"
runat="server"
DataTextField="Name"
DataValueField="TableID" >
</telerik:RadSearchBox>
您还需要更改查询字符串以在数据集中包含ID。
string comtext = "select Name, TableID from tblcustomer";
Telerik's RadSearch demo page可以举例说明如何在需要时使用SearchContext
。