?
Solved

gridview paging is not working

Posted on 2014-01-03
7
Medium Priority
?
232 Views
Last Modified: 2014-01-06
class file shown below:

Imports Microsoft.VisualBasic


Public Class TTReportsChangeofAddressExceptionGridView
    Inherits TTReportsGridViewFiller
    Implements IReportResult

    'Private _userId As Integer
    Private _userType As String
    Private _plpId As Integer

    Public Sub New(ByVal sDealers As String, ByVal sFinalizeDateFrom As String, ByVal sFinalizeDateTo As String, ByVal sExceptionSource As String)

        MyBase.New()

        _Dealers = WebFormHelper.ToSqlString(sDealers)

        Try : DateTime.TryParse(sFinalizeDateFrom, _FinalizedDateFrom)
        Catch ex As Exception : _FinalizedDateFrom = SqlTypes.SqlDateTime.Null : End Try

        Try : DateTime.TryParse(sFinalizeDateTo, _FinalizedDateTo)
        Catch ex As Exception : _FinalizedDateTo = SqlTypes.SqlDateTime.Null : End Try

        _ExceptionSource = WebFormHelper.ToSqlString(IIf(String.IsNullOrEmpty(sExceptionSource), "both", sExceptionSource.ToLower()))

        _UserID = UserSession.UserID
        _userType = Security.GetRuleValue("user_type")
        _plpId = UserSession.PrivateLabelPartnerID

    End Sub

    Public Overrides Sub DataBind(ByRef gv As GridView, ByVal iSortField As Integer, ByVal iSortDirection As Integer, ByRef dtOutput As DataTable, Optional ByVal bBindGrid As Boolean = True)

        Dim sStoredProc = "spTTReports_AddressException"

        Dim arrSqlParameters As SqlParameter() = { _
            New SqlParameter("@dealers", _Dealers), _
            New SqlParameter("@finaldatefrom", _FinalizedDateFrom), _
            New SqlParameter("@finaldateto", _FinalizedDateTo), _
            New SqlParameter("@exceptionSource", _ExceptionSource), _
            New SqlParameter("@plpId", _plpId), _
            New SqlParameter("@userId", _UserID), _
            New SqlParameter("@userType", _userType) _
            }

        Dim arrDSColumnNames() As String = {"t21 ID", "Deal #", "Dealer Name", "Customer Name", _
                                             "Old Address", "New Address", _
                                            "Deal Date", "Days Since Deal", _
                                            "Finalized Date", "Days Since Finalized", _
                                            "Source", "Transmitted Date"}

        MyBase.DataBind(gv, iSortField, iSortDirection, sStoredProc, arrSqlParameters, arrDSColumnNames)
        dtOutput = _dt

        If bBindGrid Then
            AddHandler gv.RowDataBound, AddressOf gv_RowDataBound

            MyBase.FillGridView(gv)
        End If

    End Sub

    Private Sub gv_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

        If e.Row.RowType = DataControlRowType.Header Then
            For i As Integer = 0 To e.Row.Cells.Count - 1
                Dim txt As String = CType(e.Row.Cells(i).Controls(0), LinkButton).Text
                Dim href As New HtmlAnchor
                href.InnerText = txt
                href.HRef = "javascript:sortGrid(" + (i + 1).ToString() + ");"

                e.Row.Cells(i).Controls.Clear()
                e.Row.Cells(i).Controls.Add(href)
            Next
        End If

        ' cause a string like "blah;blah;blah" to appear in a column
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.Cells(3).Text = e.Row.Cells(3).Text.Replace(";", ";<br>")
        End If

    End Sub

    Public Sub PrepareGrid(ByVal gv As System.Web.UI.WebControls.GridView) Implements IReportResult.PrepareGrid
        gv.AllowPaging = True
        gv.AllowSorting = True
    End Sub

    Public Sub PrepareGridViewColumns(ByRef gv As System.Web.UI.WebControls.GridView, ByVal SelectedDate As String) Implements IReportResult.PrepareGridViewColumns
        Dim col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12 As New BoundField
        col1.HeaderText = "t21 ID"
        col1.DataField = "t21 ID"
        col1.SortExpression = "1"

        col2.HeaderText = "Deal #"
        col2.DataField = "Deal #"
        col2.SortExpression = "2"

        col3.HeaderText = "Dealer Name"
        col3.DataField = "Dealer Name"
        col3.SortExpression = "3"

        col4.HeaderText = "Customer Name"
        col4.DataField = "Customer Name"
        col4.SortExpression = "4"

        col5.HeaderText = "Old Address"
        col5.DataField = "Old Address"
        col5.SortExpression = "5"

        col6.HeaderText = "New Address"
        col6.DataField = "New Address"
        col6.SortExpression = "6"

        col7.HeaderText = "Deal Date"
        col7.DataField = "Deal Date"
        col7.SortExpression = "7"

        col8.HeaderText = "Days Since Deal"
        col8.DataField = "Days Since Deal"
        col8.SortExpression = "8"
        col8.ItemStyle.HorizontalAlign = HorizontalAlign.Center

        col9.HeaderText = "Finalized Date"
        col9.DataField = "Finalized Date"
        col9.SortExpression = "9"

        col10.HeaderText = "Days Since Final"
        col10.DataField = "Days Since Finalized"
        col10.SortExpression = "10"
        col10.ItemStyle.HorizontalAlign = HorizontalAlign.Center

        col11.HeaderText = "Source"
        col11.DataField = "Source"
        col11.SortExpression = "11"

        col12.HeaderText = "Transmitted Date"
        col12.DataField = "Transmitted Date"
        col12.SortExpression = "12"

        gv.Columns.Add(col1)
        gv.Columns.Add(col2)
        gv.Columns.Add(col3)
        gv.Columns.Add(col4)
        gv.Columns.Add(col5)
        gv.Columns.Add(col6)
        gv.Columns.Add(col7)
        gv.Columns.Add(col8)
        gv.Columns.Add(col9)
        gv.Columns.Add(col10)
        gv.Columns.Add(col11)
        gv.Columns.Add(col12)
    End Sub

    Public Function PrepareModifiedColumnName(ByVal ColumnName As String) As String Implements IReportResult.PrepareModifiedColumnName
        Return ColumnName
    End Function

    Public Sub PrepareReportHTML(ByVal tbl As System.Web.UI.WebControls.Table, ByVal dt As System.Data.DataTable) Implements IReportResult.PrepareReportHTML
        Dim bDisplayColumnTotals As Boolean = False

        Dim tr As New TableRow
        Dim td(dt.Columns.Count - 1) As TableCell
        Dim arrTotal(dt.Columns.Count - 1) As Double
        Dim bSubTotal As Boolean = True

        For i As Integer = LBound(td) To UBound(td)
            td(i) = New TableCell()
            td(i).Text = PrepareModifiedColumnName(dt.Columns(i).ColumnName)
            td(i).Font.Names = New String() {"Arial"}
            td(i).Font.Size = FontUnit.Point(8)
            td(i).Font.Bold = True
            td(i).Wrap = True

            td(i).Style("border-bottom") = "2px solid black"
            tr.Cells.Add(td(i))

            ' Reset Column Totals
            If bDisplayColumnTotals Then arrTotal(i) = 0
        Next
        tbl.Rows.Add(tr)

        For r As Integer = 0 To dt.Rows.Count - 1
            tr = New TableRow
            For i As Integer = LBound(td) To UBound(td)
                td(i) = New TableCell()
                td(i).Font.Names = New String() {"Arial"}
                td(i).Font.Size = FontUnit.Point(8)
                If IsDBNull(dt.Rows(r)(i)) Then
                    td(i).Text = ""
                Else
                    td(i).Text = dt.Rows(r)(i)
                End If

                If r Mod 2 = 0 Then
                    td(i).BackColor = Drawing.Color.FromArgb(255, 255, 255)
                Else
                    td(i).BackColor = Drawing.Color.FromArgb(225, 225, 225)
                End If

                '' Check if this is a SubTotal Row
                'bSubTotal = False
                'If bSubTotal Then
                '    td(i).BackColor = Drawing.Color.FromArgb(201, 202, 203)
                'End If

                '' Add to Total
                'If bDisplayColumnTotals Then
                '    If IsNumeric(dt.Rows(r)(i)) Then
                '        arrTotal(i) = arrTotal(i) + dt.Rows(r)(i)
                '    End If
                'End If

                If (i = 6 OrElse i = 8) Then
                    td(i).HorizontalAlign = HorizontalAlign.Center
                End If

                tr.Cells.Add(td(i))
            Next
            tbl.Rows.Add(tr)
        Next

        ' Optionally display Footer
        If bDisplayColumnTotals Then
            tr = New TableRow

            For i As Integer = LBound(td) To UBound(td)
                td(i) = New TableCell()

                td(i).Text = arrTotal(i)

                td(i).Font.Names = New String() {"Arial"}
                td(i).Font.Size = FontUnit.Point(8)
                td(i).Font.Bold = True
                td(i).Wrap = True
                td(i).Style("border-top") = "2px solid black"
                tr.Cells.Add(td(i))
            Next
            tbl.Rows.Add(tr)
        End If

    End Sub

    Public Sub PrepareReportSpecificGridView(ByVal divCanvas As System.Web.UI.HtmlControls.HtmlGenericControl, ByVal lbl As System.Web.UI.WebControls.Label, ByVal ddlPageSize As System.Web.UI.WebControls.DropDownList) Implements IReportResult.PrepareReportSpecificGridView
        divCanvas.Style.Add("width", "1550px")
    End Sub

    Public Sub PrepareReportSpecificVariables(ByRef dt As System.Data.DataTable, _
                                              ByRef xslFile As String, _
                                              ByRef ReportTitle As String, _
                                              ByVal bTotalColumns As Boolean) Implements IReportResult.PrepareReportSpecificVariables
        'xslFile = "ScanningExceptions.xsl"
        ReportTitle = "Change of Address Exceptions"
    End Sub

End Class

Open in new window

0
Comment
Question by:Meinhoonaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39754345
Any error messages or is it doing nothing?
0
 

Author Comment

by:Meinhoonaa
ID: 39754351
No error messages, it is doing nothing.
0
 
LVL 10

Expert Comment

by:Monica P
ID: 39755997
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39758341
Do you have a pageIndexChanging Event? If so does your code ever hit it? I have found that when you dynamically create gridviews you need to manually handle the paging and sorting events as well.

See Akila P's link for a couple of examples.
0
 

Author Comment

by:Meinhoonaa
ID: 39758434
can u send me the links?
0
 
LVL 10

Accepted Solution

by:
Monica P earned 2000 total points
ID: 39758635
For Example :

In aspx :

<asp:GridView ID="GridVwPagingSorting" runat="server" AutoGenerateColumns="False"
                Font-Names="Verdana" AllowPaging="True" AllowSorting="True" PageSize="5" Width="75%"
               OnPageIndexChanging="PageIndexChanging" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" OnSorting="Sorting">

In Code :

protected void PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridVwPagingSorting.PageIndex = e.NewPageIndex;
            DataView dvEmployee = Getdata();
            GridVwPagingSorting.DataSource = dvEmployee;
            GridVwPagingSorting.DataBind();
        }
0
 

Author Closing Comment

by:Meinhoonaa
ID: 39759850
tks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question