【发布时间】:2019-03-29 03:35:25
【问题描述】:
我想通过 webapi 从数据库中获取数据并显示在 listview 中,但是使用 lsitview 我想使用分页。我正在使用 syncfusion 进行列表视图分页。我已经完成了一些工作,但我遇到了错误
我得到的错误是“无法将当前 JSON 对象(例如 {“name”:“value”})反序列化为类型 'System.Collections.Generic.List`1'
private List<products> products = new List<products>();
var httpClient = new HttpClient();
var json = await httpClient.GetStringAsync("http://orangepotato.rjcpacking.com/index.php?route=api/login/getFeaturedProducts");
protected async void FeaturedList()
{ products = JsonConvert.DeserializeObject<List<products>>(json);
dataPager.Source = products;
}
void Handle_OnDemandLoading(object sender, Syncfusion.SfDataGrid.XForms.DataPager.OnDemandLoadingEventArgs e)
{
var source= products.Skip(e.StartIndex).Take(e.PageSize);
FeaturedlistView.ItemsSource = source.AsEnumerable();
}
【问题讨论】: