我们正在跟踪分页指南-https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page?view=aspnetcore-2.1,并且在分页的“下一个”和“上一个”按钮方面存在问题:
严重性代码描述项目文件行抑制状态 错误CS1061“ IList”没有 包含“ HasPreviousPage”的定义,没有可访问的扩展名 方法'HasPreviousPage'接受类型的第一个参数 可以找到“ IList”( 您缺少using指令或程序集引用吗?)
import 'package:flutter/material.dart';
import 'package:connectivity/connectivity.dart';
void main() => runApp(MaterialApp(title: "Wifi Check", home: MyPage()));
class MyPage extends StatefulWidget {
@override
_MyPageState createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
bool _tryAgain = false;
@override
void initState() {
super.initState();
_checkWifi();
}
_checkWifi() async {
// the method below returns a Future
var connectivityResult = await (new Connectivity().checkConnectivity());
bool connectedToWifi = (connectivityResult == ConnectivityResult.wifi);
if (!connectedToWifi) {
_showAlert(context);
}
if (_tryAgain != !connectedToWifi) {
setState(() => _tryAgain = !connectedToWifi);
}
}
@override
Widget build(BuildContext context) {
var body = Container(
alignment: Alignment.center,
child: _tryAgain
? RaisedButton(
child: Text("Try again"),
onPressed: () {
_checkWifi();
})
: Text("This device is connected to Wifi"),
);
return Scaffold(
appBar: AppBar(title: Text("Wifi check")),
body: body
);
}
void _showAlert(BuildContext context) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text("Wifi"),
content: Text("Wifi not detected. Please activate it."),
)
);
}
}
有什么想法吗?
我确实有PaginatedList.cs类:
/*
Write a program in C language that in sequence:
1) create 2 pipes and a child (the 2 pipes will be used for two-way communication between the parent
and son);
2) the father, after the creation of the child, takes in input from the user a file name;
3) send the child the name of the file using the first pipe;
4) make the child look for the number of spaces in the file and communicate this number to the father through the use of the second pipe;
5) let the father print the number received from son;
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
int main (int argc, char *argv[])
{
int f2s[2];
int s2f[2];
int fd, n;
pid_t p;
char buf[20];
char c;
int countspace=0, valueofspace;
if (argc<2)
{
printf("ERROR!\n");
exit (-1);
}
if (pipe (f2s) == -1 && pipe (s2f) == -1)
exit(-1);
p=fork();
if (p>0)
{
printf("I'm inside the father process.\n");
close(f2s[0]);
close(s2f[1]);
write(f2s[1],argv[1],sizeof(argv[1]));
read(s2f[0],&valueofspace, sizeof(int));
printf("The spaces are %d", valueofspace);
printf("Father exit\n");
exit(0);
}
if (p==0)
{
printf("I'm inside the child process.\n");
close(f2s[1]);
close(s2f[0]);
read (f2s[0],buf,20);
if (fd = open(buf, O_RDONLY) == -1)
printf("Error when opening the file\n");
while (read(fd,&c,1) > 0)
{
if (c==' ')
countspace++;
}
close(fd);
printf("Count: %d\n",countspace);
n = write(s2f[1],&countspace, sizeof(countspace));
printf("WRITE of %d BYTES\n", n);
printf("Son exit \n");
exit(0);
}
}
这是该index.cshtml的后端代码:
@{
var prevDisabled = !Model.TournamentAtheletes.HasPreviousPage ? "disabled" : "";
var nextDisabled = !Model.TournamentAtheletes.HasNextPage ? "disabled" : "";
}
<a asp-page="./Index"
asp-route-sortOrder="@Model.CurrentSort"
asp-route-pageIndex="@(Model.TournamentAtheletes.PageIndex - 1)"
asp-route-currentFilter="@Model.CurrentFilter"
class="btn btn-default @prevDisabled">
Previous
</a>
<a asp-page="./Index"
asp-route-sortOrder="@Model.CurrentSort"
asp-route-pageIndex="@(Model.TournamentAtheletes.PageIndex + 1)"
asp-route-currentFilter="@Model.CurrentFilter"
class="btn btn-default @nextDisabled">
Next
</a>
答案 0 :(得分:2)
通过这样声明您的列表:
IList<TournamentAtheleteViewModel> TournamentAtheletes { get; set; }
您明确指出,保证存在的唯一方法是由接口IList<T>
声明的方法,而该接口未声明HasPreviousPage
或HasNextPage
发生这种情况的原因是我声明:
IList<TournamentAtheleteViewModel> TournamentAtheletes = new List<TournamentAtheleteViewModel>();
List<T>
当然不会声明您的方法,因此如果我调用.HasPreviousPage
,这将导致运行时异常。
因此,您需要将此声明更改为:
PaginatedList<TournamentAtheleteViewModel> TournamentAtheletes { get; set; }