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....
sub button2_click(s ender as object,e as eventargs)
'con.close()
dim da as sqldataadapter, ds as dataset
dim con as sqlconnection
dim griditem as datagriditem
dim kk as boolean
dim row as integer
con=new sqlconnection(" server=WADHWA;u ser id=sa;pwd=;init ial catalog=OnlineS hoppingDatabase ")
con.open()
da=new SqlDataAdapter( )
da.selectcomman d=new SqlCommand()
da.selectcomman d.connection=co n
da.selectcomman d.commandtext=" insert temp_info values(@BookId, @CatId,@Title,@ Author,@Publish er,@Price,@Quan tity)"
da.selectcomman d.parameters.ad d(new sqlparameter("@ BookId",SqlDbTy pe.Int,0,"BookI d"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ CatId",SqlDbTyp e.Int,0,"CatId" ))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Title",SqlDbTyp e.varchar,10,"T itle"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Author",SqlDbTy pe.varchar,10," Author"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Publisher",SqlD bType.varchar,1 0,"Publisher" ))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Price",SqlDbTyp e.float,0,"Pric e"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Quantity",SqlDb Type.Int,0,"Qua ntity"))
for each griditem in datagrid1.items
'chk=griditem.c ells(0).findcon trol("checkbox" )
'kk=directcast( griditem.Cells( 1).Controls(0), CheckBox).check ed
da.selectcomman d.parameters("@ BookId").value= integer.parse(g riditem.cells(8 ).text)
da.selectcomman d.parameters("@ CatId").value=i nteger.parse(gr iditem.cells(9) .text)
da.selectcomman d.parameters("@ Title").value=g riditem.cells(2 ).text
da.selectcomman d.parameters("@ Author").value= griditem.cells( 3).text
da.selectcomman d.parameters("@ Publisher").val ue=griditem.cel ls(4).text
da.selectcomman d.parameters("@ Price").value=d ecimal.parse(gr iditem.cells(5) .text.Replace(" ", ""), Globalization.N umberStyles.All owThousands or Globalization.N umberStyles.All owCurrencySymbo l or Globalization.N umberStyles.All owDecimalPoint)
da.selectcomman d.parameters("@ Quantity").valu e=integer.parse (griditem.cells (6).text)
kk=directcast(g riditem.cells(0 ).findcontrol(" checkbox1"),che ckbox).checked
if kk then
'response.write ("checked")
row =da.selectcomma nd.executenonqu ery()
end if
row=0
next
ds=new DataSet
da.fill(ds,"tem p_info")
session("temp") =ds
'ds = nothing
'da=nothing
con.close()
response.redire ct("webform6.as px")
end sub
<--------------------------------------------------------------------------------------------------------------->
Then, I retrieve this dataset on the page load event of "webform6.aspx" .Here is the code.....
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'If Not Page.IsPostBack Then
If Session("temp") Is Nothing Then
ds = New DataSet
da = New SqlDataAdapter
con = New SqlConnection(" server=WADHWA;u ser id=sa;pwd=;init ial catalog=onlines hoppingdatabase ")
con.Open()
da.SelectComman d = New SqlCommand("sel ect * from temp_info", con)
da.Fill(ds, "temp_info" )
'DataGrid1.Data Source = ds
'DataGrid1.Data Source = ds.Tables("temp _info")
DataGrid1.DataB ind()
End If
If Not Page.IsPostBack Then
'DataGrid1.Enab leViewState = False
ds = New DataSet
ds = CType(Session(" temp"), DataSet)
DataGrid1.DataS ource = ds
DataGrid1.DataB ind()
End If
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
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....
sub button2_click(s ender as object,e as eventargs)
'con.close()
dim da as sqldataadapter, ds as dataset
dim con as sqlconnection
dim griditem as datagriditem
dim kk as boolean
dim row as integer
con=new sqlconnection(" server=WADHWA;u ser id=sa;pwd=;init ial catalog=OnlineS hoppingDatabase ")
con.open()
da=new SqlDataAdapter( )
da.selectcomman d=new SqlCommand()
da.selectcomman d.connection=co n
da.selectcomman d.commandtext=" insert temp_info values(@BookId, @CatId,@Title,@ Author,@Publish er,@Price,@Quan tity)"
da.selectcomman d.parameters.ad d(new sqlparameter("@ BookId",SqlDbTy pe.Int,0,"BookI d"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ CatId",SqlDbTyp e.Int,0,"CatId" ))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Title",SqlDbTyp e.varchar,10,"T itle"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Author",SqlDbTy pe.varchar,10," Author"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Publisher",SqlD bType.varchar,1 0,"Publisher" ))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Price",SqlDbTyp e.float,0,"Pric e"))
da.selectcomman d.parameters.ad d(new sqlparameter("@ Quantity",SqlDb Type.Int,0,"Qua ntity"))
for each griditem in datagrid1.items
'chk=griditem.c ells(0).findcon trol("checkbox" )
'kk=directcast( griditem.Cells( 1).Controls(0), CheckBox).check ed
da.selectcomman d.parameters("@ BookId").value= integer.parse(g riditem.cells(8 ).text)
da.selectcomman d.parameters("@ CatId").value=i nteger.parse(gr iditem.cells(9) .text)
da.selectcomman d.parameters("@ Title").value=g riditem.cells(2 ).text
da.selectcomman d.parameters("@ Author").value= griditem.cells( 3).text
da.selectcomman d.parameters("@ Publisher").val ue=griditem.cel ls(4).text
da.selectcomman d.parameters("@ Price").value=d ecimal.parse(gr iditem.cells(5) .text.Replace(" ", ""), Globalization.N umberStyles.All owThousands or Globalization.N umberStyles.All owCurrencySymbo l or Globalization.N umberStyles.All owDecimalPoint)
da.selectcomman d.parameters("@ Quantity").valu e=integer.parse (griditem.cells (6).text)
kk=directcast(g riditem.cells(0 ).findcontrol(" checkbox1"),che ckbox).checked
if kk then
'response.write ("checked")
row =da.selectcomma nd.executenonqu ery()
end if
row=0
next
ds=new DataSet
da.fill(ds,"tem p_info")
session("temp") =ds
'ds = nothing
'da=nothing
con.close()
response.redire ct("webform6.as px")
end sub
<--------------------------------------------------------------------------------------------------------------->
Then, I retrieve this dataset on the page load event of "webform6.aspx" .Here is the code.....
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'If Not Page.IsPostBack Then
If Session("temp") Is Nothing Then
ds = New DataSet
da = New SqlDataAdapter
con = New SqlConnection(" server=WADHWA;u ser id=sa;pwd=;init ial catalog=onlines hoppingdatabase ")
con.Open()
da.SelectComman d = New SqlCommand("sel ect * from temp_info", con)
da.Fill(ds, "temp_info" )
'DataGrid1.Data Source = ds
'DataGrid1.Data Source = ds.Tables("temp _info")
DataGrid1.DataB ind()
End If
If Not Page.IsPostBack Then
'DataGrid1.Enab leViewState = False
ds = New DataSet
ds = CType(Session(" temp"), DataSet)
DataGrid1.DataS ource = ds
DataGrid1.DataB ind()
End If
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