mercredi 28 mai 2014

System.Data.DataRow' does not contain a definition for 'Item'


Vote count:

0




I'm attempting to control a datagridview from a TreeView control and also converting from VB.Net to C# and Have encountered an error on these two lines :



sRef = lWADataBaseDataSet.orderTBL.Rows[I].Item[0];
sOrder = lWADataBaseDataSet.orderTBL.Rows[I].Item[1];


The code from this tutorial is (containing my database information):



if treeView1.SelectedNode is nothing then
orderTBLDataGridView.DataSource = nothing
exit sub
end if
if treeview1.SelectedNod.Name = "root" then
orderTBLDataGridView.DataSource = nothing
exit sub
end if

dim sRef as string
sRef = treeview1.SelectedNode.name
orderTBLDataGridView.DataSource = lWADataBaseDataSet.orderTBL("id=" & id);


All code :



public void ordersForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'lWADataBaseDataSet.orderTBL' table. You can move, or remove it, as needed.
this.orderTBLTableAdapter.Fill(this.lWADataBaseDataSet.orderTBL);
string sRef = null;
string sOrder = null;
int I = 0;
for (I = 0; (I
<= (lWADataBaseDataSet.orderTBL.Count - 1)); I++)
{

sRef = lWADataBaseDataSet.orderTBL.Rows[I].Item[0];
sOrder = lWADataBaseDataSet.orderTBL.Rows[I].Item[1];

treeView1.Nodes[0].Nodes.Add(sRef, sOrder);
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
if ((treeView1.SelectedNode == null)) {
orderTBLDataGridView.DataSource = null;
return;
}
if ((treeView1.SelectedNode.Name == "root")) {
orderTBLDataGridView.DataSource = null;
return;
}
string sRef;
sRef = treeView1.SelectedNode.Name;
orderTBLDataGridView.DataSource = lWADataBaseDataSet.orderTBL.Select(("Reference=" + sRef));

}


asked 35 secs ago






Aucun commentaire:

Enregistrer un commentaire