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

BindingSource with hierarchic tables

4 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yael
Top achievements
Rank 1
Yael asked on 19 Jun 2008, 11:45 AM
Hello
I am testing the GridView in order to buy it if it answer my needs.
I am lookin for an example of how to bind the gridview to the dataset through a BindingSource.
Something like:

Add relation = "Table1_Table2", "Table1" & "Table2"

masterBindingSource.DataSource = myDataSet;
masterBindingSource.DataMember = "Table1";

detailBindingSource.DataSource = masterBindingSource;
detailBindingSource.DataMember = "Table1_Table2";

gridView1.DataSource = masterBindingSource;
gridView1.DataMember =  "Table1_Table2";


In your example i see that i have to create the GridViewTemplate & relation & MasterGridViewTemplate.ChildGridViewTemplate.
But you are not using the BindingSource.

Can you give an example of using a BindingSource for hierarchic of 2 tables?

Thanks Yael

4 Answers, 1 is accepted

Sort by
0
Yael
Top achievements
Rank 1
answered on 19 Jun 2008, 12:32 PM
Hi again
I tried the following example but get an error:

The code is:

masterBindingSource.DataSource = myDataSet;
masterBindingSource.DataMember = "Table1";

detailBindingSource.DataSource = myDataSet;
detailBindingSource.DataMember = "Table2";

GridViewTemplate filesTemplate = new GridViewTemplate(gridSources);
filesTemplate.AllowAddNewRow = false;

gridSources.MasterGridViewTemplate.ChildGridViewTemplate.Add(filesTemplate);
 
filesTemplate.DataSource = detailBindingSource;
gridSources.DataSource = masterBindingSource;

GridViewRelation relation = new GridViewRelation(gridSources.MasterGridViewTemplate);
relation.RelationName = "Sources Files";

relation.ParenColumnNames.Add("Server_id");
relation.ChildColumnNames.Add("Server_id");

relation.ChildTemplate = filesTemplate;
gridSources.Relations.Add(relation);

The error I am getting is:
"Sort string contains a property that is not in the IBindingList" (etc...)

Please tell me if i am on the right way.

I don't want to use direct bind to DataSet.
The bind should be through BindingSource.

Thanks again Yael
0
Nikolay
Telerik team
answered on 20 Jun 2008, 04:06 PM
Hello Yael,

Thank you for your interest in our products.

RadGridView supports the scenario of binding two data tables in a hierarchy by the means of a BindingSource.
I have attached a sample project which follows your code and demonstrates this approach.

The exception coming from your code snippet is most likely to have happened because you are setting incorrect column names to the parent and child columns of the relation.

I will be glad to help you further if you have additional questions.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Yael
Top achievements
Rank 1
answered on 29 Jun 2008, 04:29 AM
Hi
The problem was that i wrote the database name of the column:
relation.ParenColumnNames.Add("Server_Id");
This returned an error.

I fixed it like this: Use the upper case of the column name:
relation.ParenColumnNames.Add("SERVER_ID");
relation.ChildColumnNames.Add("SERVER_ID");

This fixed the problem, is this a known issue?

Thanks Yael
0
Nikolay
Telerik team
answered on 01 Jul 2008, 02:20 PM
Hello Yael,

Thank you for bringing this into our attention.

Currently, the mechanism for the columns, when building а relation, is case sensitive and that's why you are observing this wrong behavior. This will be addressed in one of our next releases.

Your Telerik points account is updated for the report. If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Yael
Top achievements
Rank 1
Answers by
Yael
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or