Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 sqldatasource select statement

Author  Topic 

orlando876
Starting Member

15 Posts

Posted - 2010-08-04 : 12:22:44
i have a sqldatadource on my page aspx but i need to upon page load base on the select statement if there is a record in the select command redirect to another page with result from the query. i am having trouble getting it done
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim username As String = Page.User.Identity.Name
SqlDataSource1.InsertParameters("Userid").DefaultValue = username
CheckReorderStatus()
End Sub

Protected Sub CheckReorderStatus()
Dim dv As DataView
Dim reorderedProducts As String

dv = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
reorderedProducts = CType(dv.Table.Rows(0)(0), String)
If (reorderedProducts > 0) Then
lblerrorbox.Text = "Number of products on reorder: " & reorderedProducts
Else
lblerrorbox.Text = "No products on reorder."
End If
End Sub

rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-15 : 05:36:53
store the result in DataView in the Session object and use Response.Redirect("your target page") to redirect to other page. On the targets's page Page_Load you can retrieve the result from Session object.

Session["MyData"] = dv

On target page:

DatView dv =(Ctype)(Session["MyData"],DataView)
Go to Top of Page
   

- Advertisement -