Reputation: 21
I can't seem to be able to be access elements that my DataRow has pulled from my DataTable, I haven't had that much practice with c# either
This is my code:
DataRow[] results = dt.Select("[Acc No] = '"+ search +"'");
I have tried casting teh objects from datarow to a string but that was not working. Search is just a string from a textbox.
When debugging i can see the items array with all the data in it so i know the select is working, can anyone help?
Upvotes: 0
Views: 292
Reputation: 34793
You need to provide more code that that... Such as how you're trying to access the contents of a DataRow
. To get a value out of the row, I believe the syntax would be something like results[rowNumber][columnNumber/name]
I.e. results[0][0]
to get the first column value out of the first row, or results[0]["Id"]
to get the "Id" column from the first row.
Of course you should check results.Count()
before attempting to access the DataRow
array.
Upvotes: 1