缺少       
 DataView Source = ds.Tables["customers"].DefaultView;
mydatagrid.datasource=Source;

解决方案 »

  1.   


    我写的是c#的
    vb的要这么写
     DataView Source = ds.Tables("customers").DefaultView
    mydatagrid.datasource=Source
      

  2.   

    你看一看这个排序功能的:<%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %><html>
    <script language="C#" runat="server">    SqlConnection myConnection;    protected void Page_Load(Object sender, EventArgs e) 
        {
            myConnection =new SqlConnection("data source=你的ip;user id=sa;password=;initial catalog=pubs");        if (!IsPostBack)
                BindGrid("au_id");
        }    protected void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e) 
        {
            BindGrid(e.SortExpression);
        }    public void BindGrid(String sortfield) 
        {
            SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection);        DataSet ds = new DataSet();
            myCommand.Fill(ds, "Authors");        DataView Source = ds.Tables["Authors"].DefaultView;
            Source.Sort = sortfield;        MyDataGrid.DataSource=Source;
            MyDataGrid.DataBind();
        }</script><body>  <h3><font face="Verdana">Sorting Data in a DataGrid Control</font></h3>  <form runat="server">    <ASP:DataGrid id="MyDataGrid" runat="server" OnSortCommand="MyDataGrid_Sort"
          Width="700"
          BackColor="#ccccff" 
          BorderColor="black"
          ShowFooter="false" 
          CellPadding=3 
          CellSpacing="0"
          Font-Name="Verdana"
          Font-Size="8pt"
          HeaderStyle-BackColor="#aaaadd"
          AllowSorting="true" 
        />  </form></body>
    </html>
    在sql server上用
    在"你的ip"出改为你自己的ip 要是本机的sql server可以写localhost
    user 为用户名
    password是密码这样就可以运行了