I have a rad grid and textbox that is in an UpdatePanel. The grid has paging, dynamic tooltips on mouse over, and it's datasource is a sql stored procedure
I have a text box that is not within the grid that I want to use to filter. I'm able to get the AJAX manager called when text is entered into the field. However, I'm having issues with the filtering.
I can't see what I'm missing...
ASPX:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="False" CodeFile="StaffByName.aspx.vb" Inherits="Staff_Staff" title="Yellow Pages" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register Src="~/UserControls/StaffProfile.ascx" TagName="StaffProfile" TagPrefix="uc1" %>
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var timer = null;
function KeyUp()
{
if (timer != null)
{
clearTimeout(timer);
}
timer = setTimeout(LoadTable,500);
}
function LoadTable()
{
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("StaffGrid");
}
</script>
</telerik:RadCodeBlock>
<div id="titleBar">Staff by Name</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Search: <asp:TextBox ID="TextBox1" onkeyup="KeyUp();" runat="server"></asp:TextBox>
<telerik:RadGrid ID="StaffGrid" runat="server" PageSize="20" AllowPaging="True"
DataSourceID="sdsStaffView" GridLines="None" AutoGenerateColumns="False" AllowSorting="True">
<ClientSettings EnableRowHoverStyle="true">
</ClientSettings>
<MasterTableView DataKeyNames="UserID">
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="UserID" DataType="System.Int64" HeaderText="UserID"
ReadOnly="True" SortExpression="UserID" UniqueName="UserID" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UserName" DataType="system.string" HeaderText="User"
SortExpression="UserName" UniqueName="UserName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Title" DataType="system.int32" HeaderText="Title"
SortExpression="Title" UniqueName="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Ext" DataType="system.datetime" HeaderText="Ext"
SortExpression="Ext" UniqueName="Ext">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CostCenter" DataType="system.datetime" HeaderText="Cost Center"
SortExpression="CostCenter" UniqueName="CostCenter">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Office" DataType="system.datetime" HeaderText="Office"
SortExpression="Office" UniqueName="Office">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<FilterMenu EnableTheming="True">
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
OnAjaxUpdate="RadToolTipManager1_AjaxUpdate" Position="Center"
Sticky="false" OffsetY="0" BackColor="#45473F" BorderColor="#45473F"
BorderWidth="0px" EnableTheming="True">
</telerik:RadToolTipManager>
<asp:repeater id="repeater1" runat="server" datasourceid="sdsStaffView" Visible="False">
<itemtemplate>
<div>
<asp:label id="lblName" runat="server"><%#Eval("UserID")%></asp:label>
</div>
</itemtemplate>
</asp:repeater>
<asp:SqlDataSource ID="sdsStaffView" runat="server"
ConnectionString="<%$ ConnectionStrings:AppConnectionString %>"
SelectCommand="proc_xUserProfileStaffByNameView"
SelectCommandType="StoredProcedure" FilterExpression="UserName='{0}' ">
<FilterParameters>
<asp:ControlParameter Name="Search" ControlId="TextBox1" PropertyName="Text"/>
</FilterParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="UpdatePanel1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="UpdatePanel1" LoadingPanelID="RadAjaxLoadingPanel1"/>
</UpdatedControls>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="TextBox1" LoadingPanelID="RadAjaxLoadingPanel1"/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
style="border: 0px;" />
</telerik:RadAjaxLoadingPanel>
</asp:Content>
ASPX.VB:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.IO
Partial Public Class Staff_Staff
Inherits System.Web.UI.Page
Dim count As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Me.RadToolTipManager1.TargetControls.Clear()
End If
End Sub
Protected Sub RadToolTipManager1_AjaxUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.ToolTipUpdateEventArgs) 'Handles RadToolTipManager1.AjaxUpdate
Me.UpdateToolTip(e.Value, e.UpdatePanel)
End Sub
Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)
Dim ctrl As Control = Page.LoadControl("~\UserControls\StaffProfile.ascx")
panel.ContentTemplateContainer.Controls.Add(ctrl)
Dim details As StaffProfile = DirectCast(ctrl, StaffProfile)
details.UserID = CType(elementID, Integer)
End Sub
Protected Sub StaffGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles StaffGrid.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem OrElse e.Item.ItemType = GridItemType.Item Then
Dim requestRowView As DataRowView = TryCast(e.Item.DataItem, DataRowView)
If requestRowView IsNot Nothing Then
Dim reqID As Integer = CInt(requestRowView("UserID"))
Dim gridItem As GridDataItem = TryCast(e.Item, GridDataItem)
Dim target As New ToolTipTargetControl(gridItem.ClientID, CType(reqID, String), True)
RadToolTipManager1.TargetControls.Add(target)
End If
End If
End Sub
Protected Sub StaffGrid_PageIndexChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) Handles StaffGrid.PageIndexChanged
RadToolTipManager1.TargetControls.Clear()
End Sub
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
If e.Argument.IndexOf("StaffGrid") <> -1 Then
If Me.TextBox1.Text = "" Then
StaffGrid.MasterTableView.FilterExpression = ""
Else
StaffGrid.MasterTableView.FilterExpression = Me.TextBox1.Text
End If
StaffGrid.DataBind()
End If
End Sub
I have a text box that is not within the grid that I want to use to filter. I'm able to get the AJAX manager called when text is entered into the field. However, I'm having issues with the filtering.
I can't see what I'm missing...
ASPX:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="False" CodeFile="StaffByName.aspx.vb" Inherits="Staff_Staff" title="Yellow Pages" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register Src="~/UserControls/StaffProfile.ascx" TagName="StaffProfile" TagPrefix="uc1" %>
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var timer = null;
function KeyUp()
{
if (timer != null)
{
clearTimeout(timer);
}
timer = setTimeout(LoadTable,500);
}
function LoadTable()
{
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("StaffGrid");
}
</script>
</telerik:RadCodeBlock>
<div id="titleBar">Staff by Name</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Search: <asp:TextBox ID="TextBox1" onkeyup="KeyUp();" runat="server"></asp:TextBox>
<telerik:RadGrid ID="StaffGrid" runat="server" PageSize="20" AllowPaging="True"
DataSourceID="sdsStaffView" GridLines="None" AutoGenerateColumns="False" AllowSorting="True">
<ClientSettings EnableRowHoverStyle="true">
</ClientSettings>
<MasterTableView DataKeyNames="UserID">
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="UserID" DataType="System.Int64" HeaderText="UserID"
ReadOnly="True" SortExpression="UserID" UniqueName="UserID" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UserName" DataType="system.string" HeaderText="User"
SortExpression="UserName" UniqueName="UserName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Title" DataType="system.int32" HeaderText="Title"
SortExpression="Title" UniqueName="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Ext" DataType="system.datetime" HeaderText="Ext"
SortExpression="Ext" UniqueName="Ext">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CostCenter" DataType="system.datetime" HeaderText="Cost Center"
SortExpression="CostCenter" UniqueName="CostCenter">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Office" DataType="system.datetime" HeaderText="Office"
SortExpression="Office" UniqueName="Office">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<FilterMenu EnableTheming="True">
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
OnAjaxUpdate="RadToolTipManager1_AjaxUpdate" Position="Center"
Sticky="false" OffsetY="0" BackColor="#45473F" BorderColor="#45473F"
BorderWidth="0px" EnableTheming="True">
</telerik:RadToolTipManager>
<asp:repeater id="repeater1" runat="server" datasourceid="sdsStaffView" Visible="False">
<itemtemplate>
<div>
<asp:label id="lblName" runat="server"><%#Eval("UserID")%></asp:label>
</div>
</itemtemplate>
</asp:repeater>
<asp:SqlDataSource ID="sdsStaffView" runat="server"
ConnectionString="<%$ ConnectionStrings:AppConnectionString %>"
SelectCommand="proc_xUserProfileStaffByNameView"
SelectCommandType="StoredProcedure" FilterExpression="UserName='{0}' ">
<FilterParameters>
<asp:ControlParameter Name="Search" ControlId="TextBox1" PropertyName="Text"/>
</FilterParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="UpdatePanel1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="UpdatePanel1" LoadingPanelID="RadAjaxLoadingPanel1"/>
</UpdatedControls>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="TextBox1" LoadingPanelID="RadAjaxLoadingPanel1"/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
style="border: 0px;" />
</telerik:RadAjaxLoadingPanel>
</asp:Content>
ASPX.VB:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.IO
Partial Public Class Staff_Staff
Inherits System.Web.UI.Page
Dim count As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Me.RadToolTipManager1.TargetControls.Clear()
End If
End Sub
Protected Sub RadToolTipManager1_AjaxUpdate(ByVal sender As Object, ByVal e As Telerik.Web.UI.ToolTipUpdateEventArgs) 'Handles RadToolTipManager1.AjaxUpdate
Me.UpdateToolTip(e.Value, e.UpdatePanel)
End Sub
Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)
Dim ctrl As Control = Page.LoadControl("~\UserControls\StaffProfile.ascx")
panel.ContentTemplateContainer.Controls.Add(ctrl)
Dim details As StaffProfile = DirectCast(ctrl, StaffProfile)
details.UserID = CType(elementID, Integer)
End Sub
Protected Sub StaffGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles StaffGrid.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem OrElse e.Item.ItemType = GridItemType.Item Then
Dim requestRowView As DataRowView = TryCast(e.Item.DataItem, DataRowView)
If requestRowView IsNot Nothing Then
Dim reqID As Integer = CInt(requestRowView("UserID"))
Dim gridItem As GridDataItem = TryCast(e.Item, GridDataItem)
Dim target As New ToolTipTargetControl(gridItem.ClientID, CType(reqID, String), True)
RadToolTipManager1.TargetControls.Add(target)
End If
End If
End Sub
Protected Sub StaffGrid_PageIndexChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) Handles StaffGrid.PageIndexChanged
RadToolTipManager1.TargetControls.Clear()
End Sub
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
If e.Argument.IndexOf("StaffGrid") <> -1 Then
If Me.TextBox1.Text = "" Then
StaffGrid.MasterTableView.FilterExpression = ""
Else
StaffGrid.MasterTableView.FilterExpression = Me.TextBox1.Text
End If
StaffGrid.DataBind()
End If
End Sub