Datagrid problems

Discussion in 'ASP .Net Web Controls' started by ASP.NET_Klown, Apr 20, 2005.

  1. I have a DataGrid with sorting and paging that shows a query from a stored
    procedure on a "QueryPage."
    The datagrid has a templatecolumn with an Image. The Image function as a
    link for each record pulled from the database.
    Each link (with different querystring parameters) sends the user to a
    resultpage.
    This works fine, but when I on the Resultpage press the "Back" button in IE
    or right click the page and choose "Back",
    the querypage crashes. Error message: "The Page cannot be displayed"

    Is it possible to return to the Querypage with the Query intact?
    Could someone be kind enough to give me a hint?

    My code:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    dbGrid.DataBind()
    End If
    End Sub

    Sub dbGrid_PageIndexChanged(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridPageChangedEventArgs)
    dbGrid.CurrentPageIndex = e.NewPageIndex
    BindData()
    End Sub

    Sub BindData()
    Dim dt As DataTable
    Dim dr As DataRow
    dt = New DataTable()
    dt.Columns.Add(New DataColumn("var1", GetType(Integer)))
    dt.Columns.Add(New DataColumn("var2", GetType(Integer)))
    dt.Columns.Add(New DataColumn("var3", GetType(String)))
    Dim mySqlConn As SqlConnection = New
    SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
    Dim MySqlCmd As SqlCommand = New SqlCommand("proc_Procedure",
    mySqlConn)
    MySqlCmd.CommandType = CommandType.StoredProcedure

    Try
    mySqlConn.Open()
    Dim Reader7 As SqlDataReader = MySqlCmd.ExecuteReader()
    While Reader7.Read()
    dr = dt.NewRow()
    dr(0) = Reader7("var1")
    dr(1) = Reader7("var2")
    dr(2) = Reader7("var3")
    dt.Rows.Add(dr)
    End While
    Reader7.Close()
    mySqlConn.Close()
    Catch f As SqlException
    Dim trouble As New Err.errorHandling()
    trouble.writeLogFile(f.Message)
    End Try
    dbGrid.DataSource = New DataView(dt)
    dbGrid.DataBind()
    END
     
    ASP.NET_Klown, Apr 20, 2005
    #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. Ingeborg

    DataGrid problems

    Ingeborg, Jun 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    456
    Luke Zhang [MSFT]
    Jul 1, 2003
  2. Susan Baker
    Replies:
    2
    Views:
    865
    kelvSYC
    Jun 26, 2005
  3. Shelly

    Problems, problems for newbie

    Shelly, Sep 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,246
    Shelly
    Sep 3, 2007
  4. Andreas Klemt
    Replies:
    0
    Views:
    338
    Andreas Klemt
    Oct 8, 2003
  5. Sak Na rede
    Replies:
    0
    Views:
    445
    Sak Na rede
    Jan 30, 2009
Loading...

Share This Page