I have read a lot of article which explain the Master Detail DatagirdView which is from two tables(Customer and CustomerOrder) . But mine is a bit complicate, hope someone can help!
I have a Typed Dataset(Dataset1), which is from two store procedures(GetBrokerFirm, GetBroker).
I am also using the Application Blocks(SqlHelper)
Master Grid should show data from GetBrokerFirm.
Detail Grid should show data from GetBroker.
I have two issues.
1) Detailgrid show all the data instead of Mastergrid related data.
2) Detail grid is not refresh, when I select the Mastergrid.
Here is my code.
//private variable private DataSet1 _ds1 = new DataSet1(); private void Form3_Load(object sender, EventArgs e){
SqlParameter[] arParms = new SqlParameter[3];arParms[0] =
new SqlParameter("@FirstName", SqlDbType.VarChar, 50);arParms[0].Value = Broker.Firstname;
arParms[1] =
new SqlParameter("@LastName", SqlDbType.VarChar, 50);arParms[1].Value = Broker.Lastname;
arParms[2] =
new SqlParameter("@Company", SqlDbType.VarChar, 50);arParms[2].Value = Broker.Company;
//Fill the private dataset _ds
SqlHelper.FillDataset("Server=localhost;DataBase=LADS;Integrated Security=SSPI", "GetBrokerFirm", _ds1, new string[] { "BrokerFirm" }, arParms);
SqlHelper.FillDataset("Server=localhost;DataBase=LADS;Integrated Security=SSPI", "GetBroker", _ds1, new string[] { "Broker" }, arParms);
//add datarelation
DataRelation relation = new DataRelation("BrokerFirmBroker",ds1.Tables["BrokerFirm"].Columns["BrokerFirmID"], ds1.Tables["Broker"].Columns["BrokerFirmID"]);
//fill the datagrid
dgrdMaster.DataSource = _ds1.Tables["BrokerFirm"].DefaultView;
dgrdDetail.DataSource = _ds1.Tables["Broker"].DefaultView;
}

Master Detail grid with typed dataset.
helpPlease176795
Hi ,
before filling the datagrid try to add this line :
_ds1.Relations.Add(relation);
Regards,
Boaz Shalev.
Bonnie Colleen
Thanks Boaz.
It is getting close. However it is still not work. I think it is missing the datagrid.member,
so I do this and I keep getting error "Child list for field BrokerFirmBroker cannot be created." from this row
dgrdMaster.DataMember = "BrokerFirm";
This is my code.
//Fill the private dataset _dsBroker, name the tables called BrokerFirm and Broker. SqlHelper.FillDataset("Server=localhost;DataBase=LADS;Integrated Security=SSPI", "GetBrokerFirm", _ds1, new string[] { "BrokerFirm" }, arParms); SqlHelper.FillDataset("Server=localhost;DataBase=LADS;Integrated Security=SSPI", "GetBroker", _ds1, new string[] { "Broker" }, arParms); DataRelation relation = new DataRelation("BrokerFirmBroker",_ds1.Tables[
"BrokerFirm"].Columns["BrokerFirmID"],_ds1.Tables[
"Broker"].Columns["BrokerFirmID"]);_ds1.Relations.Add(relation);
dgrdMaster.DataSource = _ds1.Tables[
"BrokerFirm"].DefaultView;dgrdMaster.DataMember =
"BrokerFirm"; //Broker Firm is my table namedgrdDetail.DataSource = _ds1.Tables[
"Broker"].DefaultView;dgrdDetail.DataMember =
"BrokerFirmBroker"; //BrokerFirmBroker is my data relation name