473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to retrieve dataset from the session

7 New Member
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books to buy from the datagrid.
User can select books using checkboxes in the datagrid.

The selected books are stored in a session variable name session("temp") which is a dataset type.After storing dataset in session (in bold letters),user will redirected to next page "webform6.aspx" . Here is the code....

Expand|Select|Wrap|Line Numbers
  1. sub button2_click(sender as object,e as eventargs)
  2.   'con.close()
  3.   dim da as sqldataadapter,ds as dataset
  4.   dim con as sqlconnection
  5.   dim griditem as datagriditem
  6.   dim kk as boolean
  7.   dim row as integer
  8.     con=new sqlconnection("server=WADHWA;user id=sa;pwd=;initial catalog=OnlineShoppingDatabase")
  9.           con.open()
  10.           da=new SqlDataAdapter()
  11.           da.selectcommand=new SqlCommand()
  12.           da.selectcommand.connection=con
  13.           da.selectcommand.commandtext="insert temp_info values(@BookId,@CatId,@Title,@Author,@Publisher,@Price,@Quantity)"
  14.           da.selectcommand.parameters.add(new sqlparameter("@BookId",SqlDbType.Int,0,"BookId"))
  15.           da.selectcommand.parameters.add(new sqlparameter("@CatId",SqlDbType.Int,0,"CatId"))
  16.           da.selectcommand.parameters.add(new sqlparameter("@Title",SqlDbType.varchar,10,"Title"))
  17.           da.selectcommand.parameters.add(new sqlparameter("@Author",SqlDbType.varchar,10,"Author"))
  18.           da.selectcommand.parameters.add(new sqlparameter("@Publisher",SqlDbType.varchar,10,"Publisher"))
  19.           da.selectcommand.parameters.add(new sqlparameter("@Price",SqlDbType.float,0,"Price"))
  20.           da.selectcommand.parameters.add(new sqlparameter("@Quantity",SqlDbType.Int,0,"Quantity"))
  21.  
  22.  
  23.   for each griditem in datagrid1.items
  24.    'chk=griditem.cells(0).findcontrol("checkbox")
  25.    'kk=directcast(griditem.Cells(1).Controls(0), CheckBox).checked
  26. da.selectcommand.parameters("@BookId").value=integer.parse(griditem.cells(8).text)
  27.           da.selectcommand.parameters("@CatId").value=integer.parse(griditem.cells(9).text)
  28.           da.selectcommand.parameters("@Title").value=griditem.cells(2).text
  29.           da.selectcommand.parameters("@Author").value=griditem.cells(3).text
  30.           da.selectcommand.parameters("@Publisher").value=griditem.cells(4).text
  31.           da.selectcommand.parameters("@Price").value=decimal.parse(griditem.cells(5).text.Replace(" ", ""), Globalization.NumberStyles.AllowThousands or Globalization.NumberStyles.AllowCurrencySymbol or Globalization.NumberStyles.AllowDecimalPoint)
  32.           da.selectcommand.parameters("@Quantity").value=integer.parse(griditem.cells(6).text)    
  33.    kk=directcast(griditem.cells(0).findcontrol("checkbox1"),checkbox).checked
  34.     if kk then
  35.           'response.write("checked")
  36.       row =da.selectcommand.executenonquery()
  37.      end if
  38.      row=0
  39.     next  
  40.      ds=new DataSet
  41.     da.fill(ds,"temp_info")
  42.     session("temp")=ds    
  43.     'ds = nothing
  44.     'da=nothing
  45.     con.close()
  46.     response.redirect("webform6.aspx")
  47.   end sub

Then, I retrieve this dataset on the page load event of "webform6.aspx" .Here is the code.....

Expand|Select|Wrap|Line Numbers
  1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         'Put user code to initialize the page here
  3.         'If Not Page.IsPostBack Then
  4.         If Session("temp") Is Nothing Then
  5.             ds = New DataSet
  6.             da = New SqlDataAdapter
  7.             con = New SqlConnection("server=WADHWA;user id=sa;pwd=;initial catalog=onlineshoppingdatabase")
  8.             con.Open()
  9.             da.SelectCommand = New SqlCommand("select * from temp_info", con)
  10.             da.Fill(ds, "temp_info")
  11.             'DataGrid1.DataSource = ds
  12.             'DataGrid1.DataSource = ds.Tables("temp_info")
  13.             DataGrid1.DataBind()
  14.         End If
  15.         If Not Page.IsPostBack Then
  16.             'DataGrid1.EnableViewState = False
  17.             ds = New DataSet
  18.             ds = CType(Session("temp"), DataSet)
  19.             DataGrid1.DataSource = ds
  20.             DataGrid1.DataBind()
  21.         End If
  22.     End Sub
But, I got an error :

Exception Details: System.Web.Http Exception: The IListSource does not contain any data sources.

But, I got an error :

Exception Details: System.Web.Http Exception: The IListSource does not contain any data sources.

Help me to remove this error and give me some good knowledge on this issue
Feb 22 '07 #1
1 2415
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. Where do you use IListSource?

Please use code tags (# icon) as it makes your code easier to read. Thanks.
Feb 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1692
by: Shawn | last post by:
In my application, I have users that are registered in SQL Server. When they login, a flag is set to indicate they are logged in (dll). The procedure to set that flag uses information stored in the session variable at the time of login using HTTPContext (httpcontext.current.session.item("bitLoggedIn"). When the user logs out, I call the Session.Abandon() to change the flag to false in the Session_End. When I try to retrieve data...
6
5128
by: Vik | last post by:
A dataset is saved in session state. Then the dataset is filled out with the new records using a dataadapter. It appears then that the dataset saved in session state contains the new records even without saving the updated dataset. Why does this happen? How can I preserve the dataset saved in session state from automatical updating? Thank you.
6
1636
by: enrique | last post by:
Hello, I simpy want to place a record ID into a session variable. I know how to create session variables, I'm just can't figure out the syntax for the record item when I'm working with a dataset. I'm using vb. session(sessionName) = recordID 'from dataset or dataview Thanks, Enrique
1
5624
by: xaime | last post by:
Hi all, I have the code below. This is doing what I want, but always has the following exception: Update unable to find TableMapping or Datatable 'mytable' The code I'm using is: Try
2
2852
by: Frank | last post by:
Can I do this? I add a session var in C# and ultimatly want to pass it into a vbscript client side activeX control. This is what I have so far but get " Object Required:'name2' " error. Can anyone suggest a btter way of passing a session var into a vbscript function? <%@ Page language="c#" debug="true" ContentType="text/html"
6
492
by: tshad | last post by:
I had asked about this before, but have been unable to solve the problem. Could this be a problem with Web Services? I have 4 web services that I reference in this object. There is only one class. I have an object I am unable to put in my session. I have others that have no problem. The difference is the the one I am having problems with was created in VS 2003. The others were created using DW and compiling using the commandline...
4
9582
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack trace suggests that the server (in the web farm) ran out of memory while attempting to stream data to an ASP Session State database (SQL Server 2000) . Our test environment consists of: - 3 web servers Load Balanced - SQL Server 2000 Database...
0
1995
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books to buy from the datagrid. User can select books using checkboxes in the datagrid. The selected books are stored in a session variable name session("temp") which is a dataset type.After storing dataset in session (in bold letters),user will...
1
6429
by: Elliot | last post by:
When decrypt the xml, output "Unable to retrieve the decryption key." Can anyone help me solve the problem? I got the code from http://msdn.microsoft.com/en-us/library/ms229746.aspx using System; using System.Xml; using System.Security.Cryptography; using System.Security.Cryptography.Xml;
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.