databinding on a datagrid

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();

<b>retrieve button click</b>

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

j o hn

[2491 byte] By [Batista] at [2007-12-16]

.NET Development

Site Classified