can't get this code to work

G

graphicsxp

Hi,

WebPage Description:

Contains one datagrid with link button column and one gridview with
dropdownlist column.
<asp:LinkButton id="QueryName" runat="server" autopostback="true"
onclick="onclick"></asp:LinkButton>

<asp:DropDownList id="GroupQueries" runat="server" width = "150px"
autopostback="true"
onselectedindexchanged="OnSelectedIndexChanged"></asp:DropDownList>

A click on a linkbutton creates an instance of a Query object (that's
one of my classes), stores it in a Session variable and redirects to
Flow.aspx (all of this is actually done in RowCommand) and I'm using
the OnClick event for debugging purpose.

A selection in the dropdownlist do the same thing (see
OnSelectedIndexChange event)

How to reproduce issue:

click on a hyperlink -> postback, RowCommand, redirection to Flow.aspx
click on back button of browser
selection of a value in a dropdownlist -> postback,
OnSelectedIndexChanged, redirection to Flow.aspx
click on back button of browser
click on a hyperlink -> postback, OnSelectedIndexChanged, redirection
to Flow.aspx
As you can see something goes seriously wrong at one point.

Could you help me with this please, I'm struggling to figure out what's
wrong ?


Here is the code:

Public Sub OnSelectedIndexChanged(ByVal sender As Object, ByVal e As
EventArgs)
If CType(sender, DropDownList).SelectedItem.Value.ToString <> " "
Then
Dim q As New Query(CType(sender, DropDownList).SelectedItem.Text,
CInt(CType (sender,DropDownList).SelectedItem.Value))

Session("CurrentQuery") = q
Response.Redirect("Flow.aspx")
End If
End Sub

Public Sub onclick(ByVal sender As Object, ByVal e As EventArgs)
Stop
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not IsPostBack Then
lblWebName.Text = Session("WebName").ToString
lblUserName.Text = Me.User.Identity.Name
If Cache("dsQueries") Is Nothing Then
GetQueries()
Else
BindGrid1(Cache("dsQueries").tables("SingleQueries"))
BindGrid2(Cache("dsQueries").tables("Groups"),
Cache("dsQueries").Tables("GroupQueries"))
End If
End If
End Sub

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridView1.RowCommand

Dim QueryName As String
Dim QueryId As Integer

QueryName =
Cache("dsQueries").tables(0).Rows(e.CommandName).item("QueryName")
QueryId =
Cache("dsQueries").Tables(0).rows(e.CommandName).item("QueryId")

Dim q As New Query(QueryName, QueryId)

Session("CurrentQuery") = q

CType(GridView1.Rows(e.CommandName).FindControl("QueryName"),
LinkButton).PostBackUrl = "Flow.aspx"

Response.Redirect("Flow.aspx")

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top