Data Repeater

GrexD

Well-known member
Joined
Mar 5, 2008
Messages
95
Programming Experience
Beginner
{I'm sure this is in the wrong section, but there are just too many forums here to chose from. Please move this is you want. Sorry}

Normally, when populating controls with data from a database I create a connection and then pass a SQL statement to create a DataReader. I then loop through the DataReader and populate the controls. Because I am creating the SQL statement on the fly I can query the database joining on multiple tables to get just the columns and rows I need.

Now I'm trying to use the Data Repeater control in VS 2010. The Data Repeater is part of the Visual Basic Power Pack add on. If you don't have it, it is similar to the Data Grid. I've never used the data grid because I found it lacking. I need more control on how to display the data. The data repeater seems as though it will work in this particular instance.

So, following the numerous on-line tutorials I created a new data source and a new dataset using the wizards. I pointed the dataset to a table in my data source and then bound the dataset to the data repeater. It works but the dataset is bound to a table. I can think of very few instances where I would need to dump the data from a table on to form. I need to be able to query the table.

I need to be able to pass a SQL statement to the dataset at run-time. It needs to be able to retain the bindings to the controls or I need to be able to bind the controls at run-time.

No property jumps out at me for changing the dataset SQL statement at run-time. I can't see how to bind controls on the data repeater at time time. I can bind a data set to a data repeater at run-time, but I can figure out how to bind the controls to the dataset fields at run-time.

Any help is appreciated.

Greg
 
hi, im taking a shot in the dark here. But i think you might be looking for
VB.NET:
control.DataSource=dataset
control.DisplayMember="columnName"
and also; i don't get why you put the table data in the dataset then bind the repeater to the dataset, is it not possible to bind the repeater to the table?
Because i find it pointless and a waste of memory to use a dataset when you only have 1 table.
 
Thanks for the response. I won't reply directly to what you wrote, but iwill say that I figured it out.

If anyone else out there is struggling with this like me the key is to use stored procedures to change the rows returned not views or tables. The Select method of the dataset is all but useless when used with bound controls. Start with a view to create your dataset and bind that to the data repeater (drag and drop columns from the data source window to the data repeater). Then create one or more stored procedures that return the same columns as the view. The stored procedure will need to have the parameters for the parts of the where clause that you want to filer and group by.

Once the stored procedure is created, open the dataset in the Designer (Right-click on the dataset in the data source window and chose 'Edit Dataset with Designer'). When the designer opens you will see 2 sections, the dataset on top with the columns listed and the table adapter on the bottom with the default Fill & GetData methods. Right click on the table adapter name and choose Add. When the wizard appears you select your stored procedure instead of choosing a view or table, or making a query. You are creating a new table adapter for your dataset based on the stored procedure and this new table adapter will receive the parameters of the stored procedure in code.

Give the new stored procedure distinct names for the FillBy & GetData methods. When it is added you will see the parameters listed to the right of the Get and Fill names. Now, these new methods will be available to you in code and can be used like this…

Me.ViewTableAdapter.FillByChart(Me.Dataset.TableView, [parameter])
Me.ViewTableAdapter.GetDataByChart([parameter])
 
Back
Top