Home All Groups Group Topic Archive Search About
Author
20 Nov 2007 8:15 AM
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.

Author
20 Nov 2007 8:10 PM
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

Show quoteHide quote
"amatuer" <njoo***@gmail.com> schreef in bericht
news:6e4087e9-c8f9-4860-9f8f-1f555ee3f424@c29g2000hsa.googlegroups.com...
> 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.