Web Services
Top achievements
Rank 2
Web Services
asked on 27 Jan 2012, 09:34 PM
I'm binding a rad grid with a data table. Whenever I use the filter, I get no results back when I know I should be getting some. Any ideas why? The sorting works fine. Here's my code.
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True" AllowFilteringByColumn="true" AllowSorting="True" AutoGenerateColumns="false" PageSize="50" Height="410px" Skin="Hay"> <MasterTableView DataKeyNames="customerId" AutoGenerateColumns="false"> <Columns> <telerik:GridBoundColumn DataField="Edit" HeaderText="<span style='visibility: hidden;'>a</span>" SortExpression="Edit" UniqueName="Edit" HeaderStyle-Width="40px" AllowFiltering="false" AllowSorting="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="name" HeaderText="Name" SortExpression="name" UniqueName="name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="address" HeaderText="Address" SortExpression="address" UniqueName="address"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="city" HeaderText="City" SortExpression="city" UniqueName="city"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="state" HeaderText="State" SortExpression="state" UniqueName="state"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="zip" HeaderText="Zip" SortExpression="zip" UniqueName="zip"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="phone" HeaderText="Phone" SortExpression="phone" UniqueName="phone"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="fax" HeaderText="Fax" SortExpression="fax" UniqueName="fax"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="email" HeaderText="Email" SortExpression="email" UniqueName="email"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="additional" HeaderText="Additional Info" SortExpression="additional" UniqueName="additional" ItemStyle-Width="200"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <HeaderStyle Width="120px" /> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"> </Scrolling> </ClientSettings></telerik:RadGrid> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not (Page.IsPostBack) Then RadGrid1.DataSource = myFunctions.customerListTable() RadGrid1.DataBind() End If End Sub Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = myFunctions.customerListTable() End Sub'this function creates a data table for the customer list Public Shared Function customerListTable() Dim sql = "SELECT customerId, name, address, city, state, zip, phone, email, fax, additional FROM Customers" & _ " WHERE deleted = 'false' ORDER BY name" Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("connection").ToString Using myConn As New SqlConnection(conn) 'create the table Dim myTable As New DataTable myTable.Columns.Add("customerId") myTable.Columns.Add("edit") myTable.Columns.Add("name") myTable.Columns.Add("address") myTable.Columns.Add("city") myTable.Columns.Add("state") myTable.Columns.Add("zip") myTable.Columns.Add("phone") myTable.Columns.Add("email") myTable.Columns.Add("fax") myTable.Columns.Add("additional") myConn.Open() Dim cmd As New SqlCommand(sql, myConn) Dim reader = cmd.ExecuteReader While reader.Read() myTable.Rows.Add(reader("customerId"), "<a href=""../Customers/EditCustomer.aspx?id" & reader("customerId") & """>Edit</a>", _ reader("name"), reader("address"), reader("city"), reader("state"), reader("zip"), _ reader("phone"), reader("email"), reader("fax"), reader("additional")) End While 'while reader.read myConn.Close() Return myTable End Using 'using myConn End Function 'customerListTable15 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Jan 2012, 05:51 PM
Hello,
There is not error or issue in your code then also please remove below code and check it.
Let me know its working or not.
Thanks,
Jayesh Goyani
There is not error or issue in your code then also please remove below code and check it.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not (Page.IsPostBack) Then RadGrid1.DataSource = myFunctions.customerListTable() RadGrid1.DataBind() End If End SubLet me know its working or not.
Thanks,
Jayesh Goyani
0
Web Services
Top achievements
Rank 2
answered on 30 Jan 2012, 06:04 PM
That is not working. I already have a check for the postback in the code I posted.
0
Shinu
Top achievements
Rank 2
answered on 31 Jan 2012, 05:25 AM
Hello,
There is no need to call DataBind() method when you are binding the grid using NeedDataSource event.
-Shinu.
There is no need to call DataBind() method when you are binding the grid using NeedDataSource event.
-Shinu.
0
Web Services
Top achievements
Rank 2
answered on 31 Jan 2012, 03:09 PM
I'm not calling databind in my need data source event.
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = myFunctions.customerListTable() End Sub0
Shinu
Top achievements
Rank 2
answered on 01 Feb 2012, 06:24 AM
Hello,
Try removing the DataBind() method in the PageLoad event. Also check the following help documentation.
Advanced Data-binding (using NeedDataSource event).
-Shinu.
Try removing the DataBind() method in the PageLoad event. Also check the following help documentation.
Advanced Data-binding (using NeedDataSource event).
-Shinu.
0
Web Services
Top achievements
Rank 2
answered on 02 Feb 2012, 07:10 PM
This is what my code looks like now, the filter still does not work. I looked at that documentation, but I don't see what I'm doing wrong. I'm not filling it with an SQL adapter and is the only real difference, I could see from your example. However, I change my code to use the sqldataadapter and fill a table but I still have the same problem. Any ideas? I can provide a link to download my project if you like.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not (Page.IsPostBack) Then RadGrid1.DataSource = myFunctions.customerListTable() End If End SubProtected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.DataSource = myFunctions.customerListTable()End Sub0
Web Services
Top achievements
Rank 2
answered on 07 Feb 2012, 12:34 AM
Any help here?
0
Hello,
I recommend that you remove the data-binding of the grid on Page_Load and use Advanced Data-binding (using NeedDataSource event) only.
Please let me know whether this helps.
Regards,
Mira
the Telerik team
I recommend that you remove the data-binding of the grid on Page_Load and use Advanced Data-binding (using NeedDataSource event) only.
Please let me know whether this helps.
Regards,
Mira
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Web Services
Top achievements
Rank 2
answered on 07 Feb 2012, 03:37 PM
This is my code, it's almost exactly what the example shows. It's still not working.
Imports System.Web.UIImports System.DataImports System.Data.SqlImports System.Data.SqlClientImports Telerik.Web.UIPartial Class internal_CustomerList Inherits System.Web.UI.Page Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings("connection").ToString Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource Dim sql = "SELECT * FROM CustomerList" Dim myconn As New SqlConnection(conn) Dim adapter As New SqlDataAdapter(sql, myconn) Dim myTable As New DataTable myconn.Open() adapter.Fill(myTable) myconn.Close() RadGrid1.DataSource = myTable End SubEnd Class0
Hello,
Could you please provide more information on the issue?
Do you use the build-in filtering of the grid or custom filtering? What happens when the grid is filtered?
Looking forward to your reply.
Kind regards,
Mira
the Telerik team
Could you please provide more information on the issue?
Do you use the build-in filtering of the grid or custom filtering? What happens when the grid is filtered?
Looking forward to your reply.
Kind regards,
Mira
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Web Services
Top achievements
Rank 2
answered on 10 Feb 2012, 03:55 PM
If you look at my first post, I'm using the built in filtering. My code is very basic at this point. You can download a full copy of my site plus a backup of the db here http://dl.dropbox.com/u/4979877/site.zip The page in question is the customer list page.
0
Web Services
Top achievements
Rank 2
answered on 14 Feb 2012, 03:39 PM
Any help here?
0
Casey
Top achievements
Rank 1
answered on 14 Feb 2012, 03:57 PM
What filter value are you using, and for what column? If it is an alpha column and the case doesn't match, that might explain why you are not getting the expected results.
You may want to add GroupingSettings-CaseSensitive="false" to your RadGrid definition just to be safe.
I hope this helps!
Casey
You may want to add GroupingSettings-CaseSensitive="false" to your RadGrid definition just to be safe.
I hope this helps!
Casey
0
Web Services
Top achievements
Rank 2
answered on 14 Feb 2012, 07:23 PM
Good god, that was it, I didn't know that existed. Thanks,
0
Casey
Top achievements
Rank 1
answered on 14 Feb 2012, 07:48 PM
No problem, it's happened to me before and it is usually the first thing I check now.
Glad I could help!
Casey
Glad I could help!
Casey