Getting dataset?

Discussion in 'ASP .Net' started by Betina Andersen, Dec 1, 2006.

  1. I have a componentOne grid along with an SqlDataSource on my aspx page, now
    I want to add a new row to my grid and tries to do this:

    Dim ds As DataSet = Page.Session("MyDataset")
    Dim dt As New DataTable
    Dim dr As DataRow
    dr = dt.NewRow()
    dr.ItemArray = dt.Rows(0).ItemArray
    dr.Item("Fag") = System.DBNull.Value
    dr.Item("Tekst") = System.DBNull.Value
    dt.Rows.Add(dr)
    dt.AcceptChanges()
    wgFag.DataSource = dt
    wgFag.DataBind()

    But I get an error in this line
    dr = dt.NewRow()

    and when looking my ds is Nothing - so how do I get the dataset from my
    datasource into my ds variable?

    Thanks
    Betina
     
    Betina Andersen, Dec 1, 2006
    #1
    1. Advertising

  2. Betina Andersen

    Masudur Guest

    Hi,

    You might be getting a error like
    " There is no row at position 0."
    cause i dont see any code where you actually
    refer your dt to any datatable of the data set.

    more over sinse you are getting ds nothing. check your code where you
    assigned the data set to session

    Thanks
    Masudur
    Kaz Software Ltd.
    www.kaz.com.bd
     
    Masudur, Dec 1, 2006
    #2
    1. Advertising

  3. "Masudur" <> skrev i en meddelelse
    news:...
    > Hi,
    >
    > more over sinse you are getting ds nothing. check your code where you
    > assigned the data set to session
    >

    The data comes from a datasource on the aspx page, it is created visually
    and I can see the data in my grid - the above code is for a button I press
    to get a new row, so I know I have data in my data source - and it is set to
    a DataSet.

    Regards Betina
     
    Betina Andersen, Dec 1, 2006
    #3
  4. Betina Andersen

    Subbu Guest

    Dim dt As New DataTable
    it gives error because the dt does not the strucutre of the table ,
    that is it does not have the Column names init.
    use this i think it will work dt = ds.Tables(0).Copy

    Thank You
    Subbu


    Betina Andersen wrote:
    > I have a componentOne grid along with an SqlDataSource on my aspx page, now
    > I want to add a new row to my grid and tries to do this:
    >
    > Dim ds As DataSet = Page.Session("MyDataset")
    > Dim dt As New DataTable
    > Dim dr As DataRow
    > dr = dt.NewRow()
    > dr.ItemArray = dt.Rows(0).ItemArray
    > dr.Item("Fag") = System.DBNull.Value
    > dr.Item("Tekst") = System.DBNull.Value
    > dt.Rows.Add(dr)
    > dt.AcceptChanges()
    > wgFag.DataSource = dt
    > wgFag.DataBind()
    >
    > But I get an error in this line
    > dr = dt.NewRow()
    >
    > and when looking my ds is Nothing - so how do I get the dataset from my
    > datasource into my ds variable?
    >
    > Thanks
    > Betina
     
    Subbu, Dec 1, 2006
    #4
  5. "Subbu" <> skrev i en meddelelse
    news:...
    > Dim dt As New DataTable
    > it gives error because the dt does not the strucutre of the table ,
    > that is it does not have the Column names init.
    > use this i think it will work dt = ds.Tables(0).Copy
    >

    Sorry but it does not work - my ds keeps being Nothing so there is nothing
    to copy from, so I need to find out hw to get my data from my ds control
    into my Dim ds variable.

    Regards
    Betina
     
    Betina Andersen, Dec 1, 2006
    #5
  6. Betina Andersen

    Masudur Guest

    Betina Andersen wrote:
    > "Subbu" <> skrev i en meddelelse
    > news:...
    > > Dim dt As New DataTable
    > > it gives error because the dt does not the strucutre of the table ,
    > > that is it does not have the Column names init.
    > > use this i think it will work dt = ds.Tables(0).Copy
    > >

    > Sorry but it does not work - my ds keeps being Nothing so there is nothing
    > to copy from, so I need to find out hw to get my data from my ds control
    > into my Dim ds variable.
    >
    > Regards
    > Betina


    Hi,

    I assume you are using sqldatasource to connect to the database. and
    you are not using any typed dataset....
    did you actually put your dataset in the session?

    using sqldatasource direcly dont put your result set to session.

    Thanks
     
    Masudur, Dec 1, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,802
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    527
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    401
  4. Nedu N
    Replies:
    2
    Views:
    2,162
  5. William Gower
    Replies:
    2
    Views:
    4,146
    Brian Baker [MVP]
    Jul 26, 2004
Loading...

Share This Page