DataGrid master-detail indicator

  • Thread starter Thread starter William Ryan eMVP
  • Start date Start date
W

William Ryan eMVP

Just change your datasource to the Parent datatable instead of setting it to
the dataset and don't set any other binding properties.

If you have a Dataset (myDataset) with two tables (tblOne and tblTwo linked
by DataRelation drL) then just do this;

myParentGrid.datasource = myDataSet.Tables["tblOne"];

myChildGrid.DataSource= myDataSet.Tables["tblTwo"];

That should do it for you.... (IF this is a web grid, then call databind
after each one but that should be it).Of course you may still need to set up
a binding context and all depending on what else you are binding..but to
solve your immediate problem, this should do it for you if I understand your
goal correctly.

Cheers,

Bill
 
Microsoft make a feaure in Datagrid that support master-detail in the one
grid.
but for end user i prefer to present MD by tow grids.

on the master grids have automatic indicator (+), this is redundant, and end
user
may confuse with it.

can i remove the (+) indicator from master datagrid?
how to do that?
 
Not if you define a datarelation between them. I may misunderstand your
question... Do you essentially want the master records in one grid and the
child records in another one? So when you click on a parent record, the
corresponding stuff in the child table is shown in the other grid? If yes,
then just define a datarelation between them and bind as I specified
above. To define a datarelation, just specify a Parent Column, a Child
column and declare a new datarelation, passing in the name of the relation
(this isn't the variable name, it's an alias you want to use for it) , the
parent column(s) and the child column(s)
http://www.knowdotnet.com/articles/datarelation.html The only catch is that
just like a real databse, the types of the columns need to match as well as
the size, and you can't have any records in the child table that you do in
the parent.

Now that I think about it though, you probably already defined a relation so
you should just be able to bind.

Let me know if you have any trouble.

bill
Mtcc said:
i not understand you. if i do:
myParentGrid.datasource = myDataSet.Tables["tblOne"];

myChildGrid.DataSource= myDataSet.Tables["tblTwo"];

i lose the benefit of master-detail. the child grid is not matching to
Master??

William Ryan eMVP said:
Just change your datasource to the Parent datatable instead of setting
it
to
the dataset and don't set any other binding properties.

If you have a Dataset (myDataset) with two tables (tblOne and tblTwo linked
by DataRelation drL) then just do this;

myParentGrid.datasource = myDataSet.Tables["tblOne"];

myChildGrid.DataSource= myDataSet.Tables["tblTwo"];

That should do it for you.... (IF this is a web grid, then call databind
after each one but that should be it).Of course you may still need to
set
up
a binding context and all depending on what else you are binding..but to
solve your immediate problem, this should do it for you if I understand your
goal correctly.

Cheers,

Bill
"Mtcc" <m> wrote in message
 
i not understand you. if i do:
myParentGrid.datasource = myDataSet.Tables["tblOne"];

myChildGrid.DataSource= myDataSet.Tables["tblTwo"];

i lose the benefit of master-detail. the child grid is not matching to
Master??

William Ryan eMVP said:
Just change your datasource to the Parent datatable instead of setting it to
the dataset and don't set any other binding properties.

If you have a Dataset (myDataset) with two tables (tblOne and tblTwo linked
by DataRelation drL) then just do this;

myParentGrid.datasource = myDataSet.Tables["tblOne"];

myChildGrid.DataSource= myDataSet.Tables["tblTwo"];

That should do it for you.... (IF this is a web grid, then call databind
after each one but that should be it).Of course you may still need to set up
a binding context and all depending on what else you are binding..but to
solve your immediate problem, this should do it for you if I understand your
goal correctly.

Cheers,

Bill
"Mtcc" <m> wrote in message
 
Trust me, I wasn't recommending deleting the relation ;-). Ok, I guess I'm
still confused...Do you ultimately want Two grids or do you just want one?
Currently, do I understand you correctly that you only have 1 grid, but the
+ mechanism is potentially confusing and that's what you want to get rid of?
 
i not understand.

my question, is not about how make master-detail.
my question is, how disappearing the visual sign (+) on master Datagrid,
thanks to micrasoft about this innovation, but my user not need it!!

don't tel me to delete relation, becuse i need it to show the detail grid
(on another one).

thanks
 
it is vary simple. two grids as master-detail with relation on dataset.
but i not need the + sign on master grid! how to hide this (+) sign.
 
Then the original solution I posted should work. If you already have the
relations defined, they'll both be affected. If a grid is bound to only one
table, then it the + wont appear
 
agian

i have dataset with two tables, TablA and TableB with relation.
i have form with two grids:

gridA -->datasuorce=DS,datamember=TableA
gridB -->datasuorce=DS,datamember=RelationAtoB

all work fine. BUT i want hide the (+) sign from gridA.
(this innovation of microsoft is vary fun but my end yser not need it!!!,
bcuse he have gridB)

if i do this
gridA -->datasuorce=none,datamember=DS.TableA
i the grids not function like master detail.

now, i can guess that true answer is, that no way. the microsoft workers is
so warm about
this innovation that not think about somebody who not like it.

this is vary stupid thing, bcouse this innovation is not fit at all for end
user application.

so, have somebody that know answer for this question??
 
Both Grids need a datasource... without a datasource it's not going to do
what you want. Set the first grid's datasource to the paretn datatable, the
child grid's datasource to the child datatable. If the datarelation is
defined, it'll work
 
Back
Top