当前位置:编程学习 > C#/ASP.NET >>

菜鸟提问:gridview要另外写什么代码才能显示吗难道

我在页面里放了个button,放了个名字为cookid的输入框,放了个gridview。
为什么写了下列的代码,运行时点击button后,页面里的gridview控件没有显示出数据库表里相对应的数据呢  

  protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection cn = new SqlConnection("server=localhost;database=jtgl;user=sa;password=sa");
        SqlCommand cmd = new SqlCommand("select * from sec where case_id = '" + this.cookid.Text + "'", cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds, "sec");
        this.GridView1.DataSource = ds.Tables[0].DefaultView;
        this.DataBind();
    } --------------------编程问答-------------------- 你先断点调试下,看下ds.Tables[0]有没有值 --------------------编程问答-------------------- GridView1.DataBind(); --------------------编程问答-------------------- this.GridView1.DataBind() --------------------编程问答-------------------- this.GridView1.DataBind()。还有看下你的这个控件是不是已经自己自动生成列了。 --------------------编程问答-------------------- this.GridView1.DataBind();
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,