How to bind a data table to a collection view in .net maui

Viewed 57

Am kinda new to database but i learned alot about it and how to use it with windows forms it works great with it but when it comes to .net maui i can not bind any data table to a collection view or a list so how can i do it?

emp_tbl.Columns.Add("emp_no",typeof(int));
        emp_tbl.Columns.Add("name");

        emp_tbl.Rows.Add(new object[] {1,"ahmed"});
        emp_tbl.Rows.Add(new object[] { 2, "mohamed" });
        emp_tbl.Rows.Add(new object[] { 3, "amr" });
        emp_tbl.Rows.Add(new object[] { 4, "omer" });
        emp_tbl.Rows.Add(new object[] { 5, "ans" });

Like why is it not working like forms?

<VerticalStackLayout>
    <CollectionView  ItemsSource="{Binding Emp_tbl.Columns}">
        <CollectionView.ItemTemplate >
            <DataTemplate >
                <StackLayout>
                    
                    <Label Text="{Binding Emp_tbl.Columns[0].DefaultValue}" />
                    <Label Text="{Binding Emp_tbl.Columns[1].DefaultValue}"/>


                </StackLayout>
                
                
                
            
            </DataTemplate>
            
        </CollectionView.ItemTemplate>

    </CollectionView>
0 Answers
Related