Hello,
I am hoping someone can help me with this issue.
I have a RadTextbox (search box), a RadButton (search button), and a RadListView. I am using the NeedDataSource event to populate my list view with data. On page load, the list view loads up with data as expected. The problem comes in when I use the search box and button to refine my data.
When I click the search button to initiate the search, the NeedDataSource event fires before the RadButton Click event. Therefore, I have to click the search button twice to get my expected results. The search text is captured in the code behind on the first click event, but then doesn't apply it until the second time around. I think this is the normal behavior according to Telerik's documentation (Other Postback events occur after the NeedDataSource event in the page lifecycle - see this link)
Can someone please help? This is a very basic need, but I am really struggling with it.
Thank you, Jim
Here is a snippet of the code that I am using.
I am hoping someone can help me with this issue.
I have a RadTextbox (search box), a RadButton (search button), and a RadListView. I am using the NeedDataSource event to populate my list view with data. On page load, the list view loads up with data as expected. The problem comes in when I use the search box and button to refine my data.
When I click the search button to initiate the search, the NeedDataSource event fires before the RadButton Click event. Therefore, I have to click the search button twice to get my expected results. The search text is captured in the code behind on the first click event, but then doesn't apply it until the second time around. I think this is the normal behavior according to Telerik's documentation (Other Postback events occur after the NeedDataSource event in the page lifecycle - see this link)
Can someone please help? This is a very basic need, but I am really struggling with it.
Thank you, Jim
Here is a snippet of the code that I am using.
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"SearchButton"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"ProductsView"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"ProductView"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"ProductView"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"CartPanel"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Black"
/>
<
div
>
<
div
class
=
"searchContainer"
>
<
div
style
=
"float: left; color: #99CA3B; margin-right: 15px; font-size: 16px; font-weight: bold;"
>Search Hort Coutureā¢ Products</
div
>
<
div
class
=
"searchBox"
>
<
telerik:RadTextBox
ID
=
"SearchBox"
BackColor
=
"#191919"
ForeColor
=
"#99CA3B"
BorderColor
=
"#C9C9C9"
BorderWidth
=
"1"
Font-Size
=
"14px"
Width
=
"380"
runat
=
"server"
></
telerik:RadTextBox
>
</
div
>
<
div
class
=
"searchButton"
>
<
telerik:RadButton
ID
=
"SearchButton"
Text
=
"Search"
runat
=
"server"
></
telerik:RadButton
>
</
div
>
</
div
>
<
div
class
=
"productContainer"
>
<
asp:Panel
ID
=
"ProductPanel"
runat
=
"server"
>
<
telerik:RadListView
ID
=
"ProductView"
runat
=
"server"
Height
=
"400"
ItemPlaceholderID
=
"ItemContainer"
Skin
=
"Black"
DataKeyNames
=
"culturalInfoId,longName,seriesDesc,cultivarDesc"
AllowPaging
=
"true"
PageSize
=
"12"
>
<
LayoutTemplate
>
<
div
class="RadListView RadListView_<%# Container.Skin %>">
<
asp:PlaceHolder
ID
=
"ItemContainer"
runat
=
"server"
></
asp:PlaceHolder
>
</
div
>
<
div
style
=
"clear: both"
></
div
>
<
div
style
=
"padding: 5px;"
>
<
div
style
=
"float: left; margin-left: 30%;"
>
<
asp:Button
runat
=
"server"
ID
=
"btnFirst"
CommandName
=
"Page"
CommandArgument
=
"First"
Text
=
"First"
Enabled="<%#Container.CurrentPageIndex > 0 %>" />
<
asp:Button
runat
=
"server"
ID
=
"btnPrev"
CommandName
=
"Page"
CommandArgument
=
"Prev"
Text
=
"Prev"
Enabled="<%#Container.CurrentPageIndex > 0 %>" />
<
span
style
=
"vertical-align: middle;"
>
Page <
strong
><%#Container.CurrentPageIndex + 1 %></
strong
> of <
strong
><%#Container.PageCount %></
strong
>
</
span
>
<
asp:Button
runat
=
"server"
ID
=
"btnNext"
CommandName
=
"Page"
CommandArgument
=
"Next"
Text
=
"Next"
Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>" />
<
asp:Button
runat
=
"server"
ID
=
"btnLast"
CommandName
=
"Page"
CommandArgument
=
"Last"
Text
=
"Last"
Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>" />
</
div
>
</
div
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
div
class
=
"item"
>
<
img
class
=
"itemImage"
src
=
"<%# Eval("
standardFileName") %>" />
<
div
class
=
"itemDesc"
>
<%# Eval("seriesDesc")%> <%# Eval("cultivarDesc")%></
div
>
<
div
class
=
"itemActions"
>
<
a
onclick
=
"ShowDetail('<%# Eval("
culturalInfoId") %>');" href="javascript:void(0);">PRODUCT DETAIL</
a
>
</
div
>
</
div
>
</
ItemTemplate
>
<
EmptyItemTemplate
>
<
div
>
No Item.
</
div
>
</
EmptyItemTemplate
>
</
telerik:RadListView
>
</
asp:Panel
>
</
div
>
</
div
>
Private
Sub
ProductView_NeedDataSource(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.RadListViewNeedDataSourceEventArgs)
Handles
ProductView.NeedDataSource
Dim
sql
As
New
sqlProcedures()
Dim
products
As
New
DataSet()
Dim
contains
As
String
= Session(
"SearchText"
)
If
(contains
Is
Nothing
)
Then
products = sql.spSelectItemsBySmartSearch(
"%"
)
Else
products = sql.spSelectItemsBySmartSearch(contains)
End
If
ProductView.DataSource = products
End
Sub
Private
Sub
SearchButton_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
SearchButton.Click
Session(
"SearchText"
) = SearchBox.Text
End
Sub