windows datagrid drill down returns relation name [modified]
-
I am using datagrid control to display drill down data through a dataset. it works fine i.e. displays parent records in required manner (with a plus sign) but on click of plus in place of showing child rows it shows a link with name of relation I defined in dataset. can any one suggest me where I am missing?
With Thanks & Regards Amit Sk Sharma
modified on Wednesday, June 29, 2011 6:56 AM
-
I am using datagrid control to display drill down data through a dataset. it works fine i.e. displays parent records in required manner (with a plus sign) but on click of plus in place of showing child rows it shows a link with name of relation I defined in dataset. can any one suggest me where I am missing?
With Thanks & Regards Amit Sk Sharma
modified on Wednesday, June 29, 2011 6:56 AM
Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.
A guide to posting questions on CodeProject[^]
Dave KreskowiakActually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.
modified on Wednesday, June 29, 2011 1:14 PM
-
Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.
A guide to posting questions on CodeProject[^]
Dave KreskowiakI have more than one tables in my dataset and I have defined relationship between them. sqlDataAdapterClients.Fill(dataSetTimeTracker, "Client"); sqlDataAdapterProjects.Fill(dataSetTimeTracker, "Project"); dataSetTimeTracker.Relations.Add("Intake2Episode", dataSetTimeTracker.Tables["Client"].Columns["ClientID"], dataSetTimeTracker.Tables["Project"].Columns["ClientID"]); dataGrid1.SetDataBinding(dataSetTimeTracker, "Client"); Now my datagrid shows me rows from Client with plus sign and when I click on that plus sign it shows name of relations "Intake2Episode" as a link there in place of respective rows from Project table. wish I could share the screen shot with you. My issue lies here, I am not clear from where (which setting needs to be done)I can get actaul rows in place of relationship.
With Thanks & Regards Amit Sk Sharma
-
Actually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.
modified on Wednesday, June 29, 2011 1:14 PM
-
Actually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.
modified on Wednesday, June 29, 2011 1:14 PM
Actually, no I'm not incorrect. None of the Windows Forms grids support drilldown. I don't know what you're talking about, but I'm talking about the functionality you see in Access where you click a little "+" symbol and the grid splits, showing you the related records from another table. No, the Windows Forms DataGridxxx controls do not support that.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
I have more than one tables in my dataset and I have defined relationship between them. sqlDataAdapterClients.Fill(dataSetTimeTracker, "Client"); sqlDataAdapterProjects.Fill(dataSetTimeTracker, "Project"); dataSetTimeTracker.Relations.Add("Intake2Episode", dataSetTimeTracker.Tables["Client"].Columns["ClientID"], dataSetTimeTracker.Tables["Project"].Columns["ClientID"]); dataGrid1.SetDataBinding(dataSetTimeTracker, "Client"); Now my datagrid shows me rows from Client with plus sign and when I click on that plus sign it shows name of relations "Intake2Episode" as a link there in place of respective rows from Project table. wish I could share the screen shot with you. My issue lies here, I am not clear from where (which setting needs to be done)I can get actaul rows in place of relationship.
With Thanks & Regards Amit Sk Sharma
I had to do some digging to find out which grid you were using. I said you had to say what you were using and you didn't do that. What are you using that old-ass grid for?? Nobody uses it anymore. I see what you're getting at, and what you're seeing is the expected behavior. There is no support in the DataGrid for showing the rows instead of that link. In order to get what you want, you'll either have to roll-your-own version of the DataGridView or use a third party data grid control. Just about every vendors grid supports the drill down functionality.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Actually, no I'm not incorrect. None of the Windows Forms grids support drilldown. I don't know what you're talking about, but I'm talking about the functionality you see in Access where you click a little "+" symbol and the grid splits, showing you the related records from another table. No, the Windows Forms DataGridxxx controls do not support that.
A guide to posting questions on CodeProject[^]
Dave KreskowiakI was half right. The DataGrid (but strangely, not the DataGridView) supports drilldown through relations. Here is a test case to demonstrate:
using System.Data;
using System.Windows.Forms;class Test {
DataSet ds;void SetUpData(){ ds = new DataSet(); DataTable dt = new DataTable("lookupTarget"); DataColumn c = new DataColumn("id", typeof(int)); dt.Columns.Add(c); dt.PrimaryKey = new DataColumn\[\]{ c }; c = new DataColumn("desc", typeof(string)); dt.Columns.Add(c); ds.Tables.Add(dt); dt = new DataTable("main"); c = new DataColumn("id", typeof(int)); dt.Columns.Add(c); c.AutoIncrement = true; dt.PrimaryKey = new DataColumn\[\]{ c }; c = new DataColumn("lookup", typeof(int)); dt.Columns.Add(c); ds.Tables.Add(dt); DataRelation dr; dr = new DataRelation("testRelation", ds.Tables\["main"\].Columns\["lookup"\], ds.Tables\["lookupTarget"\].Columns\["id"\], false); ds.Relations.Add(dr); } void PopulateData(){ DataRow row; DataTable lookupTarget = ds.Tables\["lookupTarget"\]; DataTable main = ds.Tables\["main"\]; row = lookupTarget.NewRow(); row\["id"\] = 1; row\["desc"\] = "Some stuff"; lookupTarget.Rows.Add(row); row = lookupTarget.NewRow(); row\["id"\] = 42; row\["desc"\] = "Don't panic"; lookupTarget.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 1; main.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 1; main.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 42; main.Rows.Add(row); } Form Form { get { Form f = new Form(); DataGrid dgv = new DataGrid(); dgv.Dock = DockStyle.Fill; dgv.DataSource = ds.Tables\["main"\]; f.Controls.Add(dgv); return f; } } static void Main(){ Test test = new Test(); test.SetUpData(); test.PopulateData(); Application.Run(test.Form); }
}
Change the variable 'dgv' to a DataGridView and it doesn't work any more. I am not aware of a way to make the expansion do anything other than show a link, though.
-
I was half right. The DataGrid (but strangely, not the DataGridView) supports drilldown through relations. Here is a test case to demonstrate:
using System.Data;
using System.Windows.Forms;class Test {
DataSet ds;void SetUpData(){ ds = new DataSet(); DataTable dt = new DataTable("lookupTarget"); DataColumn c = new DataColumn("id", typeof(int)); dt.Columns.Add(c); dt.PrimaryKey = new DataColumn\[\]{ c }; c = new DataColumn("desc", typeof(string)); dt.Columns.Add(c); ds.Tables.Add(dt); dt = new DataTable("main"); c = new DataColumn("id", typeof(int)); dt.Columns.Add(c); c.AutoIncrement = true; dt.PrimaryKey = new DataColumn\[\]{ c }; c = new DataColumn("lookup", typeof(int)); dt.Columns.Add(c); ds.Tables.Add(dt); DataRelation dr; dr = new DataRelation("testRelation", ds.Tables\["main"\].Columns\["lookup"\], ds.Tables\["lookupTarget"\].Columns\["id"\], false); ds.Relations.Add(dr); } void PopulateData(){ DataRow row; DataTable lookupTarget = ds.Tables\["lookupTarget"\]; DataTable main = ds.Tables\["main"\]; row = lookupTarget.NewRow(); row\["id"\] = 1; row\["desc"\] = "Some stuff"; lookupTarget.Rows.Add(row); row = lookupTarget.NewRow(); row\["id"\] = 42; row\["desc"\] = "Don't panic"; lookupTarget.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 1; main.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 1; main.Rows.Add(row); row = main.NewRow(); row\["lookup"\] = 42; main.Rows.Add(row); } Form Form { get { Form f = new Form(); DataGrid dgv = new DataGrid(); dgv.Dock = DockStyle.Fill; dgv.DataSource = ds.Tables\["main"\]; f.Controls.Add(dgv); return f; } } static void Main(){ Test test = new Test(); test.SetUpData(); test.PopulateData(); Application.Run(test.Form); }
}
Change the variable 'dgv' to a DataGridView and it doesn't work any more. I am not aware of a way to make the expansion do anything other than show a link, though.
I know. There's also no way to make the DataGrid show the child records. That's why I said what I did. He either has to roll his own or use a third party datagrid to do this.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak