terryxie2006 发表于 2022-8-25 09:01:54

ListView和gridView 绑定数据不显示

ListView和gridView 绑定数据数据后,页面没有显示数据。要刷新页面才有显示,是什么原因。

            DataTable gridTable = new DataTable();
            string ss = "select top(10) name as Name,inDate as SendDate,inDate as ReadDate, CardNo ,case when IsManager=1 then '1.png' else '2.png'end as image   from PersonInfo";
            gridTable = SQLHelper.ExecuteDataTable(ss);
            listView1.TemplateControlName = "ctlEditMingxi";
            listView1.DataSource = gridTable;
            listView1.DataBind();

Lula.Jin 发表于 2022-8-25 09:40:23

是在线程中更新了listview吗?是的话在线程的末尾加上 this.Client.RenderFlush();

terryxie2006 发表于 2022-8-25 09:44:20

Lula.Jin 发表于 2022-8-25 09:40
是在线程中更新了listview吗?是的话在线程的末尾加上 this.Client.RenderFlush();

private void button1_Press(object sender, EventArgs e)
      {
            listView1.DataSource = null;
            DataTable gridTable = new DataTable();
            string ss = "select top(10) name as Name,inDate as SendDate,inDate as ReadDate, CardNo ,case when IsManager=1 then '1.png' else '2.png'end as image   from PersonInfo";
            gridTable = SQLHelper.ExecuteDataTable(ss, 3135);
            listView1.TemplateControlName = "ctlEditMingxi";
            listView1.DataSource = gridTable;
            listView1.DataBind();
            this.Client.RenderFlush();
      }


是在button事件里更新

terryxie2006 发表于 2022-8-25 09:44:40

terryxie2006 发表于 2022-8-25 09:44
private void button1_Press(object sender, EventArgs e)
      {
            listView1.DataSource ...

加上去了还是不行

Lula.Jin 发表于 2022-8-25 10:09:06

    listView1.TemplateControlName = "ctlEditMingxi";改成   listView1.TemplateControl = new ctlEditMingxi(); 试试

terryxie2006 发表于 2022-8-25 10:15:26

Lula.Jin 发表于 2022-8-25 10:09
listView1.TemplateControlName = "ctlEditMingxi";改成   listView1.TemplateControl = new ctlEditMi ...

也试过了

terryxie2006 发表于 2022-8-25 10:16:54

按BUTTON后按浏览器刷新才能显示,也换了电脑,新建项目。

Lula.Jin 发表于 2022-8-25 10:21:40

    this.Form.ShowLoadingScreen("等待");
gridTable = SQLHelper.ExecuteDataTable(ss, 3135);
this.Form.CloseLoadingScreen();
这样试试

terryxie2006 发表于 2022-8-25 10:31:20

还是不行,或者有没有页面刷新的方法?

terryxie2006 发表于 2022-8-25 10:31:41

Lula.Jin 发表于 2022-8-25 10:21
this.Form.ShowLoadingScreen("等待");
gridTable = SQLHelper.ExecuteDataTable(ss, 3135);
this.For ...

还是不行,或者有没有页面刷新的方法?
页: [1] 2
查看完整版本: ListView和gridView 绑定数据不显示