can't get this code to work

Discussion in 'ASP .Net' started by graphicsxp, Mar 8, 2006.

  1. graphicsxp

    graphicsxp Guest

    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
    graphicsxp, Mar 8, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Fisher
    Replies:
    4
    Views:
    434
    =?ISO-8859-1?Q?Anders_Nor=E5s?=
    Jan 31, 2005
  2. craig dicker
    Replies:
    9
    Views:
    674
    Juan T. Llibre
    Jul 7, 2005
  3. Ranginald
    Replies:
    3
    Views:
    609
    Ray Booysen
    May 25, 2006
  4. Chris
    Replies:
    4
    Views:
    516
    Scott M.
    Jan 7, 2007
  5. Xeno Campanoli
    Replies:
    1
    Views:
    342
    James Britt
    Jul 1, 2005
Loading...

Share This Page