Hi guys, I've been struggling with a problem all day.
The scenario I want to acheive is:
With the same radsearchbox, I wanna search in 2 differents datasource.
Let me explain. On my main page, if I choose the "News" context, I wanna be able to search in my News database on 3 differents fields.
I was able to get the expected result with this code.
and the code behind
Now by choosing the "Bottin" context, I wanna be able to get the result from a business logic object named Employe from a function GetEmployeList(string name). I tried to set the new datasource of my searchbox with the result of my function, but it didn't work since i already define a datasourceID
Any hints on how I could be able to have 2 different datasource depending on the context choice?
Thank you.
The scenario I want to acheive is:
With the same radsearchbox, I wanna search in 2 differents datasource.
Let me explain. On my main page, if I choose the "News" context, I wanna be able to search in my News database on 3 differents fields.
I was able to get the expected result with this code.
<
telerik:RadSearchBox
ID
=
"rsbSearch"
runat
=
"server"
InputType
=
"Text"
TextSettings-SelectionMode
=
"Single"
DataSourceID
=
"SqlSearchDataSource"
DataValueField
=
"ID"
OnDataSourceSelect
=
"rsbSearch_DataSourceSelect"
EmptyMessage
=
"Rechercher"
Width
=
"250px"
MaxResultCount
=
"5"
>
<
SearchContext
ShowDefaultItem
=
"false"
DataKeyField
=
"Titre"
>
<
Items
>
<
telerik:SearchContextItem
Text
=
"Nouvelle"
Key
=
"News"
/>
<
telerik:SearchContextItem
Text
=
"Bottin"
Key
=
"Bottin"
/>
</
Items
>
</
SearchContext
>
<
DropDownSettings
CssClass
=
"rsbSearchPopUp"
>
<
ItemTemplate
>
<
asp:PlaceHolder
ID
=
"test1"
runat
=
"server"
>
<
table
class
=
"tableNews"
style
=
"z-index:200;"
>
<
tbody
>
<
tr
>
<
td
class
=
"actualityDescription"
>
<
table
>
<
tr
>
<
td
>.............
and the code behind
protected
void
rsbSearch_DataSourceSelect(
object
sender, SearchBoxDataSourceSelectEventArgs e)
{
SqlDataSource source = (SqlDataSource)e.DataSource;
RadSearchBox mySearchBox = (RadSearchBox)sender;
string
filterString = e.FilterString;
if
(e.SelectedContextItem !=
null
&& e.SelectedContextItem.Key.ToLower() ==
"news"
)
{
source.SelectCommand =
"SELECT TOP 100 * FROM [NewsData] WHERE DescriptionCourte Like '%"
+ filterString +
"%'"
+
" OR Titre Like '%"
+ filterString +
"%'"
+
" OR DescriptionLongue Like '%"
+ filterString +
"%'"
;
}
else
{
//mySearchBox.DataSource = Intranet.BL.Employe.GetEmployees(true, filterString);
}
}
Now by choosing the "Bottin" context, I wanna be able to get the result from a business logic object named Employe from a function GetEmployeList(string name). I tried to set the new datasource of my searchbox with the result of my function, but it didn't work since i already define a datasourceID
Any hints on how I could be able to have 2 different datasource depending on the context choice?
Thank you.