This is a migrated thread and some comments may be shown as answers.

How to change the SQL query behind a GridView

7 Answers 347 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 03 Aug 2016, 03:53 PM

I have a gridview that I have bound to a DataSet that displays a customer's address information. (Select FNAME, LNAME, STREET, CITY, STATE, ZIP FROM CUSTOMERS)

I have a textbox that a user will type a search criteria into and click a button. What I am trying to do is run the sql again with that criteria applied and return the results to the user by updating this GridView.

This should be simple and I have done it before in Access. But, I am stumped right now and could use some help.

 

Table adapter is named CUSTOMERSTableAdapter

Binding source is named CUSTOMERSBindingSource

Data set is named ECOMLIVEDataSet

If my button was named btnCustomerSearch, what code should execute on the _click event to revise the SQL?

 

Thanks in advance. Maybe somebody can point to a tutorial online somewhere or help explain this.

7 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 03 Aug 2016, 03:54 PM
PS: I am using Visual Basic but can translate if samples are provided in c#
0
Dimitar
Telerik team
answered on 04 Aug 2016, 10:25 AM
Hi Robert,

Thank you for writing.

This is not a good approach for this because retrieving the data is an expensive operation. Moreover, you already have retrieved all the data. In addition, you will have to rebind the grid, which will recreate all columns and rows again and this is an expensive operation as well. 

It would be better to use the grid default filtering functionality. In this case, you will need to add filter descriptor when the button is pressed. Detailed information is available in the following articles:
In addition, I believe that the following resources are containing what you are looking for:
I hope this will be useful. 

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Robert
Top achievements
Rank 1
answered on 04 Aug 2016, 01:24 PM

Thank you for the reply. The issue here is that the table that has the data contains about 2,500,000 customer records.

I can't see selecting all 2.5MM records and then filtering..... Not to mention, if we have 20 users using this program. 

With that in mind, do you have any other thoughts?

0
Dimitar
Telerik team
answered on 05 Aug 2016, 11:59 AM
Hello Robert,

You can use RadVirtualGrid for such scenarios. It is designed to load only part of the data and it supports filtering as well:
Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Robert
Top achievements
Rank 1
answered on 05 Aug 2016, 08:00 PM

Great, Thanks. I have been exploring the radVirtualGrid examples.

 

When I take the example source and adapter it to my SQL database, the application force-quits without any notification.  It always happens at the same point without any notification or errors thrown.

 

        If e.RowIndex = RadVirtualGrid.HeaderRowIndex Then
            e.Value = columnNames(e.ColumnIndex)
        End If

 

I set the ColumnCount and RowCount on the grid properties.... 

 

Any thoughts?

0
Robert
Top achievements
Rank 1
answered on 05 Aug 2016, 09:08 PM
I got it. I was using the wrong provider.....
0
Hristo
Telerik team
answered on 08 Aug 2016, 02:09 PM
Hello Robert,

Thank you for writing back.

I am glad that you are having the project working as expected now.

Please let me know if you need further assistance.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Dimitar
Telerik team
Hristo
Telerik team
Share this question
or