Getting dataset?

  • Thread starter Betina Andersen
  • Start date
B

Betina Andersen

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
 
M

Masudur

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
 
B

Betina Andersen

Masudur said:
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
 
S

Subbu

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
 
B

Betina Andersen

Subbu said:
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
 
M

Masudur

Betina said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top