ds.Tables("ncpdsd")===〉确定存在?

解决方案 »

  1.   

    parentrow = ds.Tables("ncpdsd").Rows(DataGrid1.SelectedIndex)  'Rows(CType(e.Item.ItemIndex, Integer))
    ===>
    parentrow = ds.Tables("ncpdsd").Rows(e.Item.ItemIndex, Integer)did you forget to fill ds.Tables("ncpdsd")?
      

  2.   

    1.Tables["ncpdsd"]===〉这里要用中括号,不是(),你确定你没有打错?
    2.Tables["ncpdsd"].Rows==>Tables["ncpdsd"].DataRows,不是Rows,你确定你没有打错?
    3.若Tables["ncpdsd"]中没有数据,则引用Tables["ncpdsd"].DataRows[index](注意这里也是中括号)就会产生“未将对象引用设置到对象的实例”异常。
      

  3.   

    If Not IsPostBack Then
                            Dim myconn As New SqlConnection("server=nikko3;database=iteminf;uid=sa;pwd=")
                myconn.Open()            Dim myAdapter1 As New SqlDataAdapter("select * from ncpdsd where flg like '023024%' or flg like '021001%'", myconn)
                myAdapter1.Fill(ds, "ncpdsd")            'Dim myAdapter2 As New SqlDataAdapter("select flg,prod_no from ncptdreq", myconn)
                'myAdapter2.Fill(ds, "ncptdreq")            myAdapter1.SelectCommand = New SqlCommand("select  top 1000 flg,prod_no from ncptdreq", myconn)
                myAdapter1.Fill(ds, "ncptdreq")            Dim arr(1) As DataColumn
                arr(0) = ds.Tables("ncpdsd").Columns("flg")
                ds.Tables("ncpdsd").PrimaryKey = arr            Dim rel As New System.Data.DataRelation("flg", ds.Tables("ncpdsd").Columns("flg"), ds.Tables("ncptdreq").Columns("flg"), False)
                ds.Relations.Add(rel)
                DataGrid1.DataSource = ds.Tables("ncpdsd").DefaultView
                DataGrid1.DataBind()            myconn.Close()
                
            End If
      

  4.   

    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
        Protected WithEvents DataGrid2 As System.Web.UI.WebControls.DataGrid
        Dim ds As New DataSet()
    但是仍然出现同样情况,datagrid1里面是可以看到数据的,只是点击选择行的时候就出现了错误。
      

  5.   

    1.
    Dim arr(1) As DataColumn
    ===>
    Dim arr(0) As DataColumn2. you used  
    "If Not IsPostBack Then"then in DataGrid1_ItemCommand, if you don't fill the dataset again, ds.Tables("ncpdsd") is null
      

  6.   

    To:Saucer
       如果每次都要填充那岂不是耗费时间?数据集是一个固定的集合(如果不进行update,insert and delete),怎么会为空呢?
      

  7.   

    If ds.Tables.Count <> 0 Then
    parentrow = ds.Tables("ncpdsd").Rows(DataGrid1.SelectedIndex)
    End If
      

  8.   

    还有一个烦恼的问题:
                          myAdapter1.SelectCommand = New SqlCommand("select  top 1000 flg,prod_no from ncptdreq", myconn)
        如果不用top 1000由于记录数太多就会出现(大概过20,可我设置的超时为2分钟),http_500.htm错误的页面。请问如何解决?
      

  9.   

    如果每次都要填充那岂不是耗费时间?数据集是一个固定的集合(如果不进行update,insert and delete),怎么会为空呢?
    网页回发后你的DataSet没有保存下来,你可以把DataSet存到Session中
      

  10.   


    我觉得保存到session中不是个好办法,没有道出问题的本质.还有兄台上面的问题希望大家提出高见.
      

  11.   

    如果不用top 1000由于记录数太多就会出现(大概过20,可我设置的超时为2分钟),http_500.htm错误的页面。请问如何解决?
    ===========>  利用数据网格分页试试!