Click here to Skip to main content
15,888,157 members
Home / Discussions / ASP.NET
   

ASP.NET

 
SuggestionRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming14-Aug-14 6:45
mveRichard Deeming14-Aug-14 6:45 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex14-Aug-14 7:01
samflex14-Aug-14 7:01 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming14-Aug-14 7:28
mveRichard Deeming14-Aug-14 7:28 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex14-Aug-14 17:07
samflex14-Aug-14 17:07 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 2:02
mveRichard Deeming18-Aug-14 2:02 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 2:54
samflex18-Aug-14 2:54 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 7:15
mveRichard Deeming18-Aug-14 7:15 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 8:04
samflex18-Aug-14 8:04 
data-type is datetime.

Here is the code for paging (kind of long sorry). Markup not included because I am not sure you want to see it.

PHP
    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
        GridView1.PageIndex = e.NewPageIndex
        showGrid()
        GridView1.DataBind()
    End Sub
    Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
        Dim gvrow As GridViewRow = GridView1.BottomPagerRow
        Dim lblcurrentpage As Label = DirectCast(gvrow.Cells(0).FindControl("CurrentPage"), Label)
        lblcurrentpage.Text = Convert.ToString(GridView1.PageIndex + 1)
        Dim page As Integer() = New Integer(6) {}
        page(0) = GridView1.PageIndex - 2
        page(1) = GridView1.PageIndex - 1
        page(2) = GridView1.PageIndex
        page(3) = GridView1.PageIndex + 1
        page(4) = GridView1.PageIndex + 2
        page(5) = GridView1.PageIndex + 3
        page(6) = GridView1.PageIndex + 4
        For i As Integer = 0 To 6
            If i <> 3 Then
                If page(i) < 1 OrElse page(i) > GridView1.PageCount Then
                    Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("p" + Convert.ToString(i)), LinkButton)
                    lnkbtn.Visible = False
                Else
                    Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("p" + Convert.ToString(i)), LinkButton)
                    lnkbtn.Text = Convert.ToString(page(i))
                    lnkbtn.CommandName = "PageNo"

                    lnkbtn.CommandArgument = lnkbtn.Text
                End If
            End If
        Next
        If GridView1.PageIndex = 0 Then
            Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("LinkButton1"), LinkButton)
            lnkbtn.Visible = False
            lnkbtn = DirectCast(gvrow.Cells(0).FindControl("LinkButton2"), LinkButton)

            lnkbtn.Visible = False
        End If
        If GridView1.PageIndex = GridView1.PageCount - 1 Then
            Dim lnkbtn As LinkButton = DirectCast(gvrow.Cells(0).FindControl("LinkButton3"), LinkButton)
            lnkbtn.Visible = False
            lnkbtn = DirectCast(gvrow.Cells(0).FindControl("LinkButton4"), LinkButton)

            lnkbtn.Visible = False
        End If
        If GridView1.PageIndex > GridView1.PageCount - 5 Then
            Dim lbmore As Label = DirectCast(gvrow.Cells(0).FindControl("nmore"), Label)
            lbmore.Visible = False
        End If
        If GridView1.PageIndex < 4 Then
            Dim lbmore As Label = DirectCast(gvrow.Cells(0).FindControl("pmore"), Label)
            lbmore.Visible = False
        End If
    End Sub
    Private Sub lb_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
        GridView1.PageIndex = Convert.ToInt32(e.CommandArgument) - 1
    End Sub
    Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

        If e.Row.RowType = DataControlRowType.Pager Then
            Dim gvr As GridViewRow = e.Row
            Dim lb As LinkButton = DirectCast(gvr.Cells(0).FindControl("p0"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command

            lb = DirectCast(gvr.Cells(0).FindControl("p1"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command
            lb = DirectCast(gvr.Cells(0).FindControl("p2"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command
            lb = DirectCast(gvr.Cells(0).FindControl("p4"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command
            lb = DirectCast(gvr.Cells(0).FindControl("p5"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command
            lb = DirectCast(gvr.Cells(0).FindControl("p6"), LinkButton)
            AddHandler lb.Command, AddressOf lb_Command
        End If
    End Sub
End Class

GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 8:38
mveRichard Deeming18-Aug-14 8:38 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 10:55
samflex18-Aug-14 10:55 
QuestionAJAX control Pin
murali_utr13-Aug-14 23:09
murali_utr13-Aug-14 23:09 
GeneralRe: AJAX control Pin
Kornfeld Eliyahu Peter13-Aug-14 23:18
professionalKornfeld Eliyahu Peter13-Aug-14 23:18 
GeneralRe: AJAX control Pin
murali_utr14-Aug-14 18:00
murali_utr14-Aug-14 18:00 
QuestionGet original string from Guid Pin
Member 947380913-Aug-14 19:06
Member 947380913-Aug-14 19:06 
AnswerRe: Get original string from Guid Pin
Bernhard Hiller13-Aug-14 21:57
Bernhard Hiller13-Aug-14 21:57 
AnswerRe: Get original string from Guid Pin
Kornfeld Eliyahu Peter13-Aug-14 22:27
professionalKornfeld Eliyahu Peter13-Aug-14 22:27 
AnswerRe: Get original string from Guid Pin
Richard MacCutchan13-Aug-14 22:28
mveRichard MacCutchan13-Aug-14 22:28 
QuestionRe: Get original string from Guid Pin
Member 947380915-Aug-14 18:49
Member 947380915-Aug-14 18:49 
QuestionDynamic Linq Query in vb.net Pin
murali_utr12-Aug-14 18:51
murali_utr12-Aug-14 18:51 
AnswerRe: Dynamic Linq Query in vb.net Pin
Bernhard Hiller12-Aug-14 21:11
Bernhard Hiller12-Aug-14 21:11 
QuestionFetch data from database based checkboxlist selection getting error Pin
Venugopal626412-Aug-14 17:34
Venugopal626412-Aug-14 17:34 
AnswerRe: Fetch data from database based checkboxlist selection getting error Pin
Bernhard Hiller12-Aug-14 21:14
Bernhard Hiller12-Aug-14 21:14 
QuestionSession variable expires even though session time was set to 9 hours. Pin
Kandepu Rajesh12-Aug-14 9:12
Kandepu Rajesh12-Aug-14 9:12 
AnswerRe: Session variable expires even though session time was set to 9 hours. Pin
Kornfeld Eliyahu Peter12-Aug-14 20:20
professionalKornfeld Eliyahu Peter12-Aug-14 20:20 
AnswerRe: Session variable expires even though session time was set to 9 hours. Pin
Swinkaran12-Aug-14 21:28
professionalSwinkaran12-Aug-14 21:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.