display last row in footer

2 posts, 0 answers
  1. Saran kumar
    Saran kumar avatar
    58 posts
    Member since:
    Sep 2009

    Posted 09 Jan 2010 Link to this post

    how to display last row of the databind in the grid in footer.
    please help.
    SURESH   avatar
    16 posts
    Member since:
    May 2009

    Posted 09 Jan 2010 Link to this post

    hello Saran kumar

    Please Try This given  code in grid itembound. Code here i am using  data field names are username, totalcost, selectdate  .i hope better useful 

      If Session("totalcost") = "" Then
                Dim dt As New DataSet
                Dim name As String = "elumalai"
                Dim sa As MySqlDataAdapter = New MySqlDataAdapter("select username, totalcost, selectdate from sourcemt.totalcost where username='" & name & "'", con)
                Dim count As Integer = dt.Tables(0).Rows.Count

                For r As Integer = 0 To dt.Tables(0).Rows.Count - 1
                    Dim username As String = dt.Tables(0).Rows(r).Item("username")
                    Dim totalcost As String = dt.Tables(0).Rows(r).Item("totalcost")
                    Dim selectdate As String = dt.Tables(0).Rows(r).Item("selectdate")
                    Session("totalcost") = totalcost
                    Session("username") = username
                    Session("selectdate") = selectdate

                MsgBox(Session("totalcost") & Session("username") & Session("selectdate"))
                Exit Sub

                If (TypeOf e.Item Is GridFooterItem) Then
                    Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
                    footerItem("username").Text = Session("username")
                    footerItem("totalcost").Text = Session("totalcost")
                    footerItem("selectdate").Text = Session("selectdate")
                End If
            End If

Back to Top