Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > can't get this code to work

Thread Tools

can't get this code to work

Posts: n/a

WebPage Description:

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

<aspropDownList id="GroupQueries" runat="server" width = "150px"

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
If CType(sender, DropDownList).SelectedItem.Value.ToString <> " "
Dim q As New Query(CType(sender, DropDownList).SelectedItem.Text,
CInt(CType (sender,DropDownList).SelectedItem.Value))

Session("CurrentQuery") = q
End If
End Sub

Public Sub onclick(ByVal sender As Object, ByVal e As EventArgs)
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
BindGrid1(Cache("dsQueries").tables("SingleQueries "))
End If
End If
End Sub

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

Dim QueryName As String
Dim QueryId As Integer

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

Dim q As New Query(QueryName, QueryId)

Session("CurrentQuery") = q

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


End Sub

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create custom base class to reuse code throughout site -- can't seem to get it to work! Ranginald ASP .Net 3 05-25-2006 01:54 PM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Mechanize: Can't get it to work. Can I help make it work next week? Xeno Campanoli Ruby 1 07-01-2005 10:32 PM
Can't get application obj to work in a code behind class Andrew Fisher ASP .Net 4 01-31-2005 11:09 AM