Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2005, 05:26 AM
Authorized User
 
Join Date: Dec 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creat a dataview and dvlop relaton betwn 2 tables

Hi

I have added a Datagrid to a form , and a button is added .
I have programmed in such a way that when the button is clicked,
from reading 2 xml files, and developing a relation between 2 tables and show it in the grid.

and that part of my program is as follows

DataSet ds = new DataSet();
DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\Relation\\cost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();

DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\Relation\\cost_type.xml");
DataTable dt2 = xml2.Tables["cost_type1"].Copy();

ds.Tables.Add(dt1);
ds.Tables.Add(dt2);

DataColumn parentCol = ds.Tables["cost_type1"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_code"].Columns["cost_type"];
DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);

dataGrid1.DataSource = ds;


now what I need is that , i have to give the dataview not the dataset.
I am not familiar with the datview.so pls anyone explain to meor change the coding part and explain .

dhol


__________________
SureShot
 
Old August 10th, 2005, 05:58 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DataView dv = new DataView(ds.Tables[0]);

I am not sure this is what you are expecting.

 
Old August 10th, 2005, 08:20 AM
Authorized User
 
Join Date: Dec 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes,
the same
but how will i code it with 2 tables.
pls explain it

dhol

 
Old August 10th, 2005, 08:51 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think this is what you need to do. Microsoft does n't support joining multiple tables in one data view. MS has created custom class that will enable to do this.

Here is the link
http://support.microsoft.com/default...b;en-us;325682


 
Old August 10th, 2005, 08:56 AM
Registered User
 
Join Date: Oct 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For C#
http://support.microsoft.com/default...b;en-us;326080


 
Old August 11th, 2005, 06:46 AM
Authorized User
 
Join Date: Dec 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
I was about to design a form witha datgrid and some buttons with certain operations namely first, previous ,next and last and some text boxes


I have to read two xml file( each xml file has one table)with data in it.
Now I have to create a relation between the two tables and display it in the datagrid.
Now using databinding I have to show the data from the datagrid columns to each text box
when teh next, previous ...etc buttons r clicked.

that is values from one column
for ex:
column name :DESC
values :MR BROS, VT BROS, CT BROS

when next is clicked, the values should be shown from the desc in to the textbox one by one.

This i have did it
this is the folowing code

private DataSet ds = new DataSeyt();

Retrieve button click

private void RetrieveButton_Click_1(object sender, System.EventArgs e)
{

DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\Relation\\cost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();

DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\Relation\\cost_type.xml");
DataTable dt2 = xml2.Tables["cost_type1"].Copy();

ds.Tables.Add(dt1);
ds.Tables.Add(dt2);


DataColumn parentCol = ds.Tables["cost_type1"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_code"].Columns["cost_type"];
DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);

this.dataGrid1.DataSource = ds.Tables["cost_type1"];
fnDataBindingforTextBoxes();
fnSetCurrencyManager();
}


private void fnDataBindingforTextBoxes()
{
this.ultraCostPaid.DataBindings.Add("Text", ds.Tables["cost_code"],"desscost_paid_by_us");
this.ultraCostType.DataBindings.Add("Text", ds.Tables["cost_code"],"cost_type");

}

private void fnSetCurrencyManager()
{
currManager=(CurrencyManager)this.BindingContext[ds.Tables["cost_code"]];
}


everything is working fine
but databinding on the grid is not used. that is if u select a row from the datagrid it should change the values in the textbox that i have already added data bindings for. if u notice just selct a row from the grid, now the values in that row should show in your textboxes you have put below.

Give a dataview for dataset
pls help me to do this

d h o l






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to creat a file object hafizmuhammadmushtaq Java Basics 3 April 8th, 2008 02:42 AM
How to creat an user account prad_a PHP Databases 1 May 12th, 2007 03:25 AM
create a relation betwn 2 tables in a dataset dhol General .NET 1 August 9th, 2005 09:17 AM
Difference betwn two topics and suggestion Kaustav JSP Basics 0 December 26th, 2003 04:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.