akgulebubekir / Maui.DataGrid

DataGrid component for Maui
MIT License
244 stars 47 forks source link

Filling DataSet from SQL Query #196

Closed VegasJohnson closed 1 month ago

VegasJohnson commented 1 month ago

C# SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds); dataview.ItemsSource = ds.Tables;

Xmal

`

#ababab #FFFFFF ` The Binding is the columns in the database.
symbiogenesis commented 1 month ago

I notice that it looks like you are trying to bind more than one table to the DataGrid.

You need to produce a collection of objects where all the records are of the same specific type. Like List<MyRecord>

Thus, you should either bind to a single table that has been casted to an enumerable, or do the equivalent of joining the tables into one collection of DataTransferObjects.

But it will need to be a more normal IEnumerable at the end. You can't bind directly to a DataTable object.

VegasJohnson commented 1 month ago

Yes , this took me gaining 30 more greys but i did achieve this methead. Thank you for following up.

On Thu, Jul 25, 2024 at 8:31 PM Edward Miller @.***> wrote:

I notice that it looks like you are trying to bind more than one table to the DataGrid, so even if you convert to a list first that isn't enough.

You need to produce a list of objects where all the records are the same.

Thus, you should either bind to a single table, or do the equivalent of joining the tables into one collection of DataTransferObjects.

But it will need to be a more normal IEnumerable at the end. You can't bind directly to a DataTable object.

— Reply to this email directly, view it on GitHub https://github.com/akgulebubekir/Maui.DataGrid/issues/196#issuecomment-2251850319, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXTAA3ZNKT6DIALEN7EH63ZOGYIBAVCNFSM6AAAAABLNUYLXCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJRHA2TAMZRHE . You are receiving this because you authored the thread.Message ID: @.***>