Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2006, 07:29 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add to datagrid without database

Hi,
I have to add details to a datagrid. but each time the submit clicked, the the page refreshes and the previous entered detail to the datagrid is lost. there is no database to save the datagrid. how do i save the details without database or just refresh the grid without postback the page?

Thanks.

annsary

 
Old March 24th, 2006, 09:59 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii annsary!!
 You can use cache object to save data,and add it new reqd items and then bind it to data grids :)

Hope this will help you.

Cheers :)

vinod
 
Old March 24th, 2006, 02:53 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Add your info into a data table, then rebind on postback.

 
Old March 28th, 2006, 06:06 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Vinod,
Thanks for your suggestion. used session to save the datatable. is cache better or session or cookie better?

jbenson001,
there is no database to insert. the program is to list user entered info and extract info for each row from a read access database.

thanks.

regards,
annsary
 
Old March 28th, 2006, 10:45 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I said data table, not database

 
Old March 28th, 2006, 08:43 PM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi jbenson001,
oops sorry. tried that method. but the data table becomes empty when postback. :(
 
Old March 29th, 2006, 12:14 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

did you put the code in an if statment?:
If NOT IsPagePostBack Then
 ..Fill data table

End IF

 
Old March 30th, 2006, 12:19 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
the datagrid will be empty when the page is first loaded. only after the user enters the data and click the add button, the data is added to the datagrid.
the datatable becomes empty at postback. the datatable is showing as 'Nothing'. all data entries before post back is lost. so how to fill?

By using the following code, I am able to add. prefer not to use session/cache/cookie as consume server resource and have to do more maitenance:
        If Not IsPostBack Then
            Bindgrd()
        Else

            If Session(SesDs) Is Nothing Then

            Else
                dsTag = CType(Session(SesDs), DataSet)
                dt = ds.Tables(sTbl)
            End If
        End If

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
        Session(SesDs) = ds
    End Sub


Private Sub bAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tRow As DataRow
        Dim itmArr() As Object = {tText1.Text, tText2.Text, tText3.Text}
        tRow = dt.NewRow()
        tRow.ItemArray = itmArr
        dt.Rows.Add(tRow)
        ds.Tables.Add(dt)
        Bindgrd()
    End Sub


Private Sub Bindgrd()

        gdataGrid.DataSource = ds
        gdataGrid.DataBind()
        gdataGrid.Visible = True
    End Sub
 
Old March 30th, 2006, 12:58 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Once the click of the button click, you do not put your data set into the session variable. Add:
Session(SesDs) = ds BEFORE the call to Bindgrd().

Not sure why you have Session(SesDs) = ds in prerender event. Seems like that will overwrite ds. And where is ds declared?

 
Old March 30th, 2006, 01:44 AM
Authorized User
 
Join Date: Mar 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
added Session(SesDs) = ds in the PreRender as this function will be called before page is rendered.
ds is declared in the Page's class section.

Public Class clUserData

    Inherits System.Web.UI.Page
    Dim ds As DataSet
    Dim dt As DataTable

annsary





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add color picker in datagrid? param99 ASP.NET 1.0 and 1.1 Professional 1 November 9th, 2006 03:57 AM
Add a Column to a DataGrid infernokodiak C# 7 January 18th, 2006 04:06 PM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Professional 0 March 13th, 2005 04:30 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Basics 0 March 13th, 2005 04:28 AM
Add records from a Datagrid dkomo VB.NET 0 May 6th, 2004 01:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.