I have mobile app project using Xamarin. Forums with MySql. I have page AboutPage.xaml :
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MyExpect.Views.AboutPage"
xmlns:vm="clr-namespace:MyExpect.ViewModels"
Title="{Binding Title}"
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
xmlns:conv="clr-namespace:DataGridSample.Views.Converters;assembly=DataGridSample">
<ContentPage.BindingContext>
<vm:AboutViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>
<dg:DataGrid x:Name="datagirdtable">
</dg:DataGrid>
</ContentPage.Content>
</ContentPage>
and AboutPage.cs :
using System;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MyExpect.Views
{
public partial class AboutPage : ContentPage
{
Connections matchs = new Connections();
public AboutPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
FillGirdView();
}
void FillGirdView() {
datagirdtable.ItemsSource = matchs.ShowData();
}
}
}
and Connection Class :
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
namespace MyExpect
{
class Connections
{
MySqlConnection connect = new
MySqlConnection("Server=localhost;Database=myexpect;uid=root;pwd=;");
public DataTable ShowData() {
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("select * from matchs", connect);
da.Fill(dt);
return dt;
}
}
}
I am trying to view Table Data on Gird Data Table ,but i receive this message : CS0266 C# Cannot implicitly convert type 'System.Data.DataTable' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)
