Showing posts with label populate. Show all posts
Showing posts with label populate. Show all posts

Thursday, March 29, 2012

Pass Object from one page to another

Hi, I have one page that has several methods that populate an ArrayList with data. I want to be able to pass this populated ArrayList to another page on the site. Is there any way that this can be done? I know values can be passed using the QueryString, but I need the whole ArrayList object to be passed.

Any help would be greatly appreciated.
Thanks

You can store it in a session variable:http://msdn2.microsoft.com/en-us/library/ms178581.aspx

From the page:

By default, session variables can be any valid .NET type. For example, the following code example stores anArrayListof values in a session variable named "StockPicks." Note that the valuereturned by the "StockPicks" session variable must be cast as theappropriate type upon retrieval from theSessionStateItemCollection.


1) You can keep the arraylist in the session object and can access the session object into another page.

2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.

Regards,

Suhas


Suhas.Chitade:

2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.

I've never tried this approach before. Would it mean that the same object is available to all users? Also, how long would the object persist?

Saturday, March 24, 2012

Passing a "where" claus to populate a datagrid on another form.

I have a form where a user can enter mulitple search criteria. Depending upon what they choose I begin stringing the information into a string field that I pass to another form.

It is my intention to open this form that contains a datagrid which returns the records that match their search criteria.

I have had success sending the information, but I am completely lost as to how I use this information.

I dragged the dbconnection, the dataadapter and created the dataset onto the form, but I am not sure if this is how I should have done it. Perhaps all of this should be done in code and create the select string in code for the dataadapter? Does anyone have code that they could share the accomplishes this?

Currently the form brings up all records, (before I started tinkering), but I do not know how to set the 'where' claus.

Thanks for your helpHere is some of the code I am working with:

Dim conn As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:\Access_ResourceDB\Access_ResourceDb_Backend\ResourceDb_be.mdb")

Dim ds As New DataSet("MyDataSet")

Dim objCmd As New OleDbDataAdapter("Select RecId,Name,Age,Town,HowmPhone,Email FROM tblContacts " & "Where " & pasRecCrit & ";", conn)

conn.Open()
objCmd.Fill(ds, "MyDataSet")
Me.DataGrid1.DataSource = ds.Tables("MyDataSet")
Me.DataGrid1.DataBind()

This is just one of the ways I have tried. Right now I get an error stating that
"No value given for one or more required parameters", on the objCmd.fill line.
Thanks
What do have in the pasRecCrit variable? This looks like it should work. Maybe your Where clause isn't formatted correctly.