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

how to make datasource work based on criteria entered in textbox

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 16 Mar 2017, 07:22 PM

I have what seems like a simple problem, but I can't seem to come up with the best way to code my grid to the datasource that I require.

 

My application is very simple.  It has a radtextbox prompt for the Customer #.   It has a radbutton for "Find Sales Orders".

In my RadGrid I want to display a list of sales order information for the customer # that the user enters.  When the user clicks on the

radbutton "Find Sales Orders", I want to execute my SQL code and populate the RadGrid with the resulting data table.   My RadGrid will also have a

telerik:GridCleintSelectColumn, because I want the user to be able to select sales orders from the grid, and when they are finished selecting sales orders, I will

have another radbutton to store those selected sales orders into another SQL table (I've already found a telerik radgrid example that shows me how to code the

events for rowselect and rowdeselect and it persists when paging back and forward.  The example also showed me how to loop through the grid and get a list of

selected key values).  This example uses a hard coded sqldatasource with a built in SQL select statement.   The data source that I

need must be driven from the customer # that the user enters and executed when the user clicks the "Find Sales Orders" button.     Does Telerik have any

examples of what I'm describing?    Everything I've found for examples so far has a built in select statement that isn't geared from other controls that a

user would typically enter on to the page.  

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 21 Mar 2017, 12:48 PM

Hi,

The grid works great when you provide a data source to it in its NeedDataSource event. This data source can be just about anything - a DataTable, an IEnumerable. So, you can built your own query and data collection there and pass it to the grid. You can use the button click to call the Rebind() method of the grid so the NeedDataSource event is called and you can pass new parameters from the textbox.

Or, you can use the ControlParameter offered by the SqlDataSource control. Basically

<asp:SqlDataSource ID="Sqldatasource1" runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="myTextBox" />
</SelectParameters>
</asp:SqlDataSource>

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or