paolol,
I assume you mean the currently selected row in a grid? If this is the
case, then what you want to do is get the binding context for the control,
and then pass the data set into it, like so:
// Get the context.
BindingContext context = dataGrid.Bindin gContext;
// Get the currency manager.
BindingManagerB ase manager = context[dataSet, memberName];
// Get the current row view.
DataRowView rowView = (DataRowView) manager.Current ;
// Get the row.
DataRow row = rowView.Row;
A few things to point out. The first parameter of the call to the
indexer for BindingContext needs to be the DataSource and the DataMember of
the data source. For example, if you bound the grid to the DataTable
directly, then just use that. If you bound to the DataSet and specified the
table name as the DataMember, then pass the data set and the member name.
You can also access the values in the row using the DataRowView.
Finally, you might just want to bind the text of the label to the
datasource directly. This is easier than setting it yourself when the
current selection changes.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard. caspershouse.co m
"paolol" <paolol@no_spam salsan.netwrote in message
news:er******** *****@TK2MSFTNG P04.phx.gbl...
Hi,
I wont to get the current row values from a dataset, any one know how to
reach those data ??
At the moment I use a work around, but it's not good ..
foreach (DataRow row in this.pitagorala voriDataSet.Add etti.Rows)
{
if (Convert.ToStri ng(row["Nome"])== sNomeU){
idutente = Convert.ToInt32 (row["id"]);
}
Because I don't want to show a label with the name ( sNomeU is =
label1.tetx )
Thanks to all.
Paolol