private static IEnumerable<User> Data ;
        public IActionResult Index(string Text ="")
        {
            string sql = "";
            if (Text == "")
            {
                sql = "select * from [User]";
            }
            else
            {
                sql = "select * from [user] where Name= '" + Text + "'";
            }
            Data = DbContext.Query<User>(sql);
            ModelState.Clear();
            return View(Data);
            
        }

解决方案 »

  1.   

    index视图没看到内容、?
    去掉
    ModelState.Clear();
      

  2.   

    不是看不到,是重新更新了下Model数据再返回,页面内容没用更新
      

  3.   

    第二次能确定参数  string Text 有值吗?
    能确定   sql = "select * from [user] where Name= '" + Text + "'";   查询的数据和第一次不同吗?
      

  4.   


    已经解决了,原因是我是用Ajax请求到的后台,好像这样子是改不了前台的页面数据的。
      

  5.   

    不是看不到,是重新更新了下Model数据再返回,页面内容没用更新去了这句也不行?
      

  6.   


    已经解决了,原因是我是用Ajax请求到的后台,好像这样子是改不了前台的页面数据的。

    ajax就是异步的。只有在success的回调函数里,才能操作页面