data to datagrid

A

amatuer

Hi, I am trying to add data to a datagrid that i get from another
page. I can add the data bt wen i add more data it replaces the
previous data. can anyone help please?

Here's my coding:

--This section gets my data from the one page and using a session i
pass a primary key to the next page.

Private Sub GetUS()
Try
Dim obj As Businesslayer.Registration = New
Businesslayer.Registration
Dim ds As Data.DataSet
ds = obj.GetUS(System.Convert.ToInt16(txtUS.Text))
obj = Nothing
'TextBox2.Items.Clear()
txtUSCode.Text = ds.Tables(0).Rows(0).Item(1)
txtDesc.Text = ds.Tables(0).Rows(0).Item(2)
txtNQF.Text = ds.Tables(0).Rows(0).Item(3)
txtCredit.Text = ds.Tables(0).Rows(0).Item(4)
txtWA.Text = ds.Tables(0).Rows(0).Item(5)
txtLT.Text = ds.Tables(0).Rows(0).Item(6)
Session("PkUS") = ds.Tables(0).Rows(0).Item(0)
'DDLTitle.DataValueField = "TitleID"
'DDLTitle.DataSource = ds
'DDLTitle.DataBind()
'DDLTitle.AppendDataBoundItems = False
Catch ex As Exception
'UserMsgBox(ex.Message)
End Try
End Sub

-- In my following page i use the session to query the data from the
database and when clicking on a button the data is added to my
datagrid. But if i select another set of data it jus replaces the
previous set.

Private Sub GetUnitStd()
Try
Dim obj As Businesslayer.Registration = New
Businesslayer.Registration
Dim ds As Data.DataSet
ds = obj.GetUnitStd(Session("PkUS"))
obj = Nothing

For Each row As GridViewRow In GVUnits.Rows
DirectCast(row.FindControl("txtName"), TextBox).Text()
= ds.Tables(0).Rows(0).Item(1)
DirectCast(row.FindControl("txtDescrip"),
TextBox).Text() = ds.Tables(0).Rows(0).Item(0)
Next


Catch ex As Exception
UserMsgBox(ex.Message)
End Try
End Sub

Can someone please assist?

Thanks.
 
C

Cor Ligthert[MVP]

Hi,

You know that the data of a webpage is not persistent, that means that you
have to save your data somewhere, the most easiest way is in a session. What
we cannot see is if you do that already. (Be aware that you need for this
the IsPostBack event).

Cor
 

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

Similar Threads

need help with array in VB 4
vb.net data 11
getting error on record duplication 18
vb.net error 2
vb.net last record in loop 2
DataGrid Style 3
vb.net string value comparision 3
vsrollbar and flowlayoutpanel 0

Top