views:

95

answers:

3

I have a Strongly typed Dataset TableAdapter in C#, how do I get a single row from it?

+1  A: 

You can try:

myTableAdapter[0];
XIII
+1  A: 
var table = tableAdapter.GetData();
var resultRow = table.Rows[0];

EDIT: Strongly-typed datasets create a property for each column in the table, so to get the Id, this should work:

int id = resultRow.Id

You can also get fields by name:

int id = (int)resultRow["id"];
Lee
how can i get for example only the ID value from this row
drorhan
@Lee var table = tableAdapter.GetData();var resultRow = table.Rows[0];i get the field name with this.
drorhan
i can not get the field list in this way
drorhan
yes this works. thank you
drorhan
A: 
       var ta = new AddressTableAdapter();

       var ret = ta.GetDataBy(Convert.ToInt32(ASPxTextBox1.Text));
       var rw = ret.Rows[0];

       var city = (string)rw["City"];


       ASPxTextBox2.Text = city.ToString();
drorhan