質問
データブルから情報を取得するにはどうすればよいですか
最初から最後まで列を取得し、それらをtextboxes.textにロードするだけです。
ClienteHolder.IDCliente = Tabla.Rows[]?????
解決
Tabla.Rows[0]["mycolumnName"]
これは、単一の列を参照する方法です。列の最初から最後までどういう意味ですか?
各列の値を保存するコントロールは何ですか?
他のヒント
通常、データセットのテーブルコレクションにアクセスしてから、テーブルの行コレクションにアクセスします。このように:
myDataSet.Tables[0] // you can also use the name of the table, instead of an integer
myTable.Rows[ n ] // this will give you the nth row in the table
myRow[ n ] // this will give you the nth column in the row, you can use the
// name of the column instead of an integer
これは、データセット内のすべてのテーブルのすべての行のすべての列を反復処理します。
foreach( DataTable curTable in myDataSet.Tables )
{
foreach( DataRow curRow in curTable.Rows )
{
foreach( DataColumn curCol in Table.Columns )
{
object item = curRow[ curCol ];
}
}
}
データテーブルのRowsプロパティはIEnumerableです。ここに行くにはLINQがより良い方法ですが、foreachループを使用して行う方法は次のとおりです(質問を正しく理解している場合)。
列を最初から最後まで取得して、それらをtextboxes.textにロードしたいだけです。
foreach(System.DataRow dr in Tabla.Rows)//iterate rows
{
foreach(System.DataColumn dc in Tabla.Columns) //iterate columns per row
{
textboxes.text = dr[dc].ToString(); //get object value at row,column
}
}
LINQはlamdaに似ていて素晴らしいですが、残念ながら、ここでは3.xをまだ使用していないので、この方法に頼り続けています。
所属していません StackOverflow