Here's what I have: Does rowdatabound or rowcommand conflict with the paging? I have paging set to 10 and there are 11 records. When I click the link at the bottom for the next page, I don't get a page with 1 record on it. It just stays on the same page
with the 10 records. How can I fix this?
End Sub
Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text & "</i>"
Dim Last As String = e.Row.Cells(1).Text
Dim social As String = e.Row.Cells(2).Text
Dim SSN As String = e.Row.Cells(2).Text
If Len(e.Row.Cells(2).Text) = 9 Then
SSN = SSN.Substring(5, 4)
e.Row.Cells(2).Text = "-" & SSN
End If
Dim datesubmitted As String = e.Row.Cells(3).Text
If datesubmitted = "1/1/1900 12:00:00 AM" Then
e.Row.Cells(3).Text = "Unsubmitted"
e.Row.Cells(4).Enabled = False 'Create DU button is enabled by default when page loads unless changed here
Else
If datesubmitted <> "1/1/1900 12:00:00 AM" Then
'find the first whitespace character
Dim i As Int16 = InStr(datesubmitted, " ")
If i <> 0 Then
datesubmitted = datesubmitted.Substring(0, i - 1) 'truncate to just a date
e.Row.Cells(3).Text = datesubmitted
End If
End If
End If
If Left(SSN, 1) = "-" Then
SSN = SSN.Substring(1, 4) ' remove the - character
End If
Dim hl As HyperLink = CType(e.Row.FindControl("Hyperlink3"), HyperLink)
'Dim path As String = "C:/mortgageloanapply/users/" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
Dim path As String = "h:\root\home\pacwest-001\www\MortgageLoanApply\users\" & Session("path") + "\" + Last + SSN + ".fnm" 'need to modify this line for server
hl.NavigateUrl = "./" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
If System.IO.File.Exists(path) Then
hl.Text = "Access"
hl.Enabled = True
Else
hl.Text = "Not Created"
hl.Enabled = False
End If
End If
End Sub
Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView2.PageIndex = e.NewPageIndex
GridView2.DataBind()
End Sub
Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
' Retrieve the row index stored in the CommandArgument property.
Dim social As Integer = Convert.ToInt32(e.CommandArgument)
CreateDUFILE(social)
End Sub
Accroding to your description and codes, I create a demo and it works fine.As far as I think,paging and rowcommand or rowdatabound is irrelevant.
I suggest you could breakpoint and debug to check if you have entered the PageIndexChanging event.Beside,you could tell us your problems.It will help us to solve your problems.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text & "</i>"
Dim Last As String = e.Row.Cells(1).Text
Dim social As String = e.Row.Cells(2).Text
Dim SSN As String = e.Row.Cells(2).Text
If Len(e.Row.Cells(2).Text) = 9 Then
SSN = SSN.Substring(5, 4)
e.Row.Cells(2).Text = "-" & SSN
End If
Dim datesubmitted As String = e.Row.Cells(3).Text
If datesubmitted = "1/1/1900 12:00:00 AM" Then
e.Row.Cells(3).Text = "Unsubmitted"
e.Row.Cells(4).Enabled = False 'Create DU button is enabled by default when page loads unless changed here
Else
If datesubmitted <> "1/1/1900 12:00:00 AM" Then
'find the first whitespace character
Dim i As Int16 = InStr(datesubmitted, " ")
If i <> 0 Then
datesubmitted = datesubmitted.Substring(0, i - 1) 'truncate to just a date
e.Row.Cells(3).Text = datesubmitted
End If
End If
End If
If Left(SSN, 1) = "-" Then
SSN = SSN.Substring(1, 4) ' remove the - character
End If
Dim hl As HyperLink = CType(e.Row.FindControl("Hyperlink3"), HyperLink)
Session("path") = "E:\"
'Dim path As String = "C:/mortgageloanapply/users/" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
Dim path As String = "C:\Users\yijings\Desktop\image" & Session("path") + "\" + Last + SSN + ".fnm" 'need to modify this line for server
hl.NavigateUrl = "./" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
If System.IO.File.Exists(path) Then
hl.Text = "Access"
hl.Enabled = True
Else
hl.Text = "Not Created"
hl.Enabled = False
End If
End If
End Sub
Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView2.PageIndex = e.NewPageIndex
GridView2.DataBind()
End Sub
Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
' Retrieve the row index stored in the CommandArgument property.
Dim social As Integer = Convert.ToInt32(e.CommandArgument)
'CreateDUFILE(social)
End Sub
Protected Sub Secondbuttoncommand(sender As Object, e As CommandEventArgs)
End Sub
Result:
Best regards,
Yijing Sun
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Hi, thanks for your response and taking a look at this. I don't have a screen recorder, but when I run it, It shows a page 2 link at the bottom, but when i click the link, I'm left on the page one with the 10 records. No page 2 with 1 record. I'm using
a master page. Could this have something to do with it? What program do you use for doing screen capture?
Accroding to your description,I create a demo with master page and it also work fine.I suggest you could breakpoint in the method of PageIndexChanging and debug to check if the event is executed.Check whether the gridview is rebind.
Besides,I suggest you could post your full codes to us.It will help us to solve your problems.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I went and copied my default.aspx file to a new default.aspx file. I also copied the code behind file piece by piece trying to find the reason it would not work. The new file works ok. So I deleted the old one and it is paging now. I downloaded and installed
the screen recording program you suggested. I have 2 screens, and in addition to recording the page showing the paging, it also recorded the contents of my other screen, so I am unable to post it here.
Member
247 Points
1310 Posts
Gridview won't do paging
Apr 12, 2020 02:08 AM|sking|LINK
Here's what I have: Does rowdatabound or rowcommand conflict with the paging? I have paging set to 10 and there are 11 records. When I click the link at the bottom for the next page, I don't get a page with 1 record on it. It just stays on the same page with the 10 records. How can I fix this?
End Sub
Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text & "</i>"
Dim Last As String = e.Row.Cells(1).Text
Dim social As String = e.Row.Cells(2).Text
Dim SSN As String = e.Row.Cells(2).Text
If Len(e.Row.Cells(2).Text) = 9 Then
SSN = SSN.Substring(5, 4)
e.Row.Cells(2).Text = "-" & SSN
End If
Dim datesubmitted As String = e.Row.Cells(3).Text
If datesubmitted = "1/1/1900 12:00:00 AM" Then
e.Row.Cells(3).Text = "Unsubmitted"
e.Row.Cells(4).Enabled = False 'Create DU button is enabled by default when page loads unless changed here
Else
If datesubmitted <> "1/1/1900 12:00:00 AM" Then
'find the first whitespace character
Dim i As Int16 = InStr(datesubmitted, " ")
If i <> 0 Then
datesubmitted = datesubmitted.Substring(0, i - 1) 'truncate to just a date
e.Row.Cells(3).Text = datesubmitted
End If
End If
End If
If Left(SSN, 1) = "-" Then
SSN = SSN.Substring(1, 4) ' remove the - character
End If
Dim hl As HyperLink = CType(e.Row.FindControl("Hyperlink3"), HyperLink)
'Dim path As String = "C:/mortgageloanapply/users/" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
Dim path As String = "h:\root\home\pacwest-001\www\MortgageLoanApply\users\" & Session("path") + "\" + Last + SSN + ".fnm" 'need to modify this line for server
hl.NavigateUrl = "./" + Session("path") + "/" + Last + SSN + ".fnm" 'need to modify this line for server
If System.IO.File.Exists(path) Then
hl.Text = "Access"
hl.Enabled = True
Else
hl.Text = "Not Created"
hl.Enabled = False
End If
End If
End Sub
Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView2.PageIndex = e.NewPageIndex
GridView2.DataBind()
End Sub
Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
' Retrieve the row index stored in the CommandArgument property.
Dim social As Integer = Convert.ToInt32(e.CommandArgument)
CreateDUFILE(social)
End Sub
California Mortgage | California refinance
Contributor
3730 Points
1408 Posts
Re: Gridview won't do paging
Apr 13, 2020 02:36 AM|yij sun|LINK
Hi sking,
Accroding to your description and codes, I create a demo and it works fine.As far as I think,paging and rowcommand or rowdatabound is irrelevant.
I suggest you could breakpoint and debug to check if you have entered the PageIndexChanging event.Beside,you could tell us your problems.It will help us to solve your problems.
More details,you could refer to below codes:
Code-behind:
Result:
Best regards,
Yijing Sun
Member
247 Points
1310 Posts
Re: Gridview won't do paging
Apr 13, 2020 05:13 AM|sking|LINK
Hi, thanks for your response and taking a look at this. I don't have a screen recorder, but when I run it, It shows a page 2 link at the bottom, but when i click the link, I'm left on the page one with the 10 records. No page 2 with 1 record. I'm using a master page. Could this have something to do with it? What program do you use for doing screen capture?
California Mortgage | California refinance
Contributor
3730 Points
1408 Posts
Re: Gridview won't do paging
Apr 13, 2020 08:59 AM|yij sun|LINK
Hi sking,
Accroding to your description,I create a demo with master page and it also work fine.I suggest you could breakpoint in the method of PageIndexChanging and debug to check if the event is executed.Check whether the gridview is rebind.
Besides,I suggest you could post your full codes to us.It will help us to solve your problems.
I suggest you could use screentogif tool.
More details,you could refer to below article:
https://github.com/NickeManarin/ScreenToGif
Best regards,
Yijing Sun
Member
247 Points
1310 Posts
Re: Gridview won't do paging
Apr 14, 2020 02:15 AM|sking|LINK
I went and copied my default.aspx file to a new default.aspx file. I also copied the code behind file piece by piece trying to find the reason it would not work. The new file works ok. So I deleted the old one and it is paging now. I downloaded and installed the screen recording program you suggested. I have 2 screens, and in addition to recording the page showing the paging, it also recorded the contents of my other screen, so I am unable to post it here.
Thanks again for you help on this.
California Mortgage | California refinance