如何使用DataView
代码:
string ds=ConfigurationSettings.AppSettings["Systen"];
SqlConnection myConnection=new SqlConnection(ds);
SqlDataAdapter fillCmd=new SqlDataAdapter("Select * from Stock_table",myConnection);
DataSet ds1 =new DataSet();
fillCmd.Fill(ds1);
不知道如何通过DataSet配合DataView使用
希望可以给个例子

解决方案 »

  1.   

    在页面中写一个方法,首先指定DataView.Source = ds1.Tables[0],然后用DataView.Bind()方法绑定一下就好了.
      

  2.   

    string ds=ConfigurationSettings.AppSettings["Systen"];
    SqlConnection myConnection=new SqlConnection(ds);
    SqlDataAdapter fillCmd=new SqlDataAdapter("Select * from Stock_table",myConnection);
    DataSet ds1 =new DataSet();
    fillCmd.Fill(ds1);
    DataView dv= new DataView(ds1.Tables[0]);//为什么这句错了
      

  3.   

    你做的是CS还是BS的程序啊?DataView不是拖放进去的吗?
    DataView dv= new DataView(ds1.Tables[0]);//这句是做什么的啊?
      

  4.   

    你写的应该没错
    只是DataView是没有Bind方法的,你看一下ps:你是要用DetailsView还是DataView?
      

  5.   

    直接强制转换  as dataView
      

  6.   


    string ds=ConfigurationSettings.AppSettings["Systen"]; 
    SqlConnection myConnection=new SqlConnection(ds); 
    SqlDataAdapter fillCmd=new SqlDataAdapter("Select * from Stock_table",myConnection); 
    DataSet ds1 =new DataSet(); 
    fillCmd.Fill(ds1); 
    -----DataView dv=ds1.Table[0].DefaultView  //这样就把dataset的数据给dataview了
      

  7.   

    string ds=ConfigurationSettings.AppSettings["Systen"]; 
    SqlConnection myConnection=new SqlConnection(ds); 
    SqlDataAdapter fillCmd=new SqlDataAdapter("Select * from Stock_table",myConnection); 
    DataSet ds1 =new DataSet(); 
    fillCmd.Fill(ds1); 
    ============================
    DataView dv=ds1.Tables[0].Defaultview //这样就把ds1中第一个table里所有的数据传给了dv
      

  8.   

    呵呵
    编程良久
    至今还未深究竟dafault view和table有啥区别。。