Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Assemblies
.NET Core
.NET Standard
Active Directory
ADO.NET
Agile Development
AJAX
Alexa Skills
Algorithms in C#
Android
Angular
Architecture
ArcObject
Artificial Intelligence
ASP.NET
ASP.NET Core
Augmented Reality
Aurelia
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blockchain
Bootstrap
Bot Framework
Business
C#
C# Corner
C, C++, MFC
Career Advice
Chapters
CIO
Cloud
COBOL.NET
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Cortana Development
Cryptocurrency
Cryptography
Crystal Reports
Current Affairs
Custom Controls
Cyber Security
Data Mining
Databases & DBA
Design Patterns & Practices
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
Expression Studio
F#
Files, Directory, IO
Games Programming
GDI+
General
Google Cloud
Google Development
Graphics Design
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Internet & Web
Internet of Things
Ionic
iOS
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
kotlin
Leadership
Learn .NET
LightSwitch
LINQ
Machine Learning
Microsoft 365
Microsoft Office
Microsoft Phone
Mobile Development
Multithreading
NetBeans
Networking
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Power BI
Printing in C#
Products
Progressive Web Apps
Project Management
Python
Q#
QlikView
R
React
Reports using C#
Robotics & Hardware
Ruby on Rails
Salesforce
Security
Servers
SharePoint
SignalR
Silverlight
Smart Devices
Software Testing
SQL Language
SQL Server
Startups
String in C#
Swift
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
WCF
Wearables
Web Development
Web Services
Web3
Windows 10
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML Standard
XML
XNA
XSharp
Register
Login
1
Answer
Grid View Pagination issue.
Rajesh Kumar
10y
629
1
Reply
Hi,
I am facing a pagination issue on my code. This is my code.
Data is coming on first redirect pagination working. as 1 and 2 but when i am clicking on 2 it redirecting to same page(page 1). then i am again clicking on 2 then it showing the 1st value of the same page. and when i click on page 1 then it showing some data and rest showing blank.
Can anyone help me on this?
Thanks
<asp:GridView ID="grdlistTeam" runat="server" AllowPaging="true"
AllowSorting="true" AutoGenerateColumns="false" DataKeyNames="Currentmatch_Id" PageSize="10"
OnPageIndexChanging="grdlistTeam_PageIndexChanging"
OnRowDataBound="grdlistTeam_RowDataBound1" ShowHeader="false"
Width="100%">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemStyle CssClass="gridViewRow" />
<ItemTemplate>
<div class="ft_lt blue_back fnt_120 white txt_center col13per line_height">
<asp:LinkButton ID="lnkTournament" runat="server" CausesValidation="false"
Font-Underline="false" ForeColor="White"
PostBackUrl='<%# Eval("TournamentId","TournamentSubHome.aspx?TournamentId={0}") %>'
Text='<%#Eval("TournamentName")%>'></asp:LinkButton>
</div>
<div class="ft_lt fnt_120 txt_center col10per line_height"
style="margin-left: 2px;">
<asp:Label ID="lbldate" runat="server" Text='<%# Eval("EventDate") %>'></asp:Label>
</div>
<div class="ft_lt txt_center col10per">
<span class="fnt_120 strong relative" style="top: 12px;">
<%# Eval("Team1Total")%>/<%# Eval("FirstInningwickets")%><br /><span class="fnt_70"><%# Eval("BallplayedTeam1")%>Ov</span></span>
</div>
<div class="ft_lt txt_center col20per" style="margin-top: 14px;">
<a class="light_blue fnt_130 line_height txt_deconone" href="">
<asp:LinkButton ID="lnkFirstTeam" runat="server" CausesValidation="false"
Font-Size="100%" Font-Underline="false" ForeColor="#0d2549"
PostBackUrl='<%# Eval("Team1_Id","TeamDetails.aspx?TeamId={0}") %>'
Text='<%#Eval("Team1") %>'></asp:LinkButton>
</a>v/s <a class="light_blue fnt_130 line_height txt_deconone" href="">
<asp:LinkButton ID="lnkSecondTeam" runat="server" CausesValidation="false"
Font-Size="100%" Font-Underline="false" ForeColor="#0d2549"
PostBackUrl='<%# Eval("Team2_Id","TeamDetails.aspx?TeamId={0}") %>'
Text='<%#Eval("Team2") %>'></asp:LinkButton>
</a>
</div>
<div class="ft_lt txt_center col10per">
<span class="fnt_120 strong relative" style="top: 12px;">
<%# Eval("Team2Total")%>/<%# Eval("SecondInningwickets")%><br /><span class="fnt_70"><%# Eval("BallplayedTeam2")%>Ov</span></span>
</div>
<div class="ft_lt txt_center col23per" style="margin-top: 13px;">
<a " class=" fnt_120="" href="#" light_blue="" relative="" txt_deconone"=""></a>
<a class="light_blue fnt_120 relative txt_deconone">
<asp:Label ID="lblResult" runat="server" Text='<%#Eval("Result") %>'></asp:Label>
</a>
<br />
<span class="fnt_150">(<a
href='<%#Eval("GroundName","stadiumprofile.aspx?name={0}") %>'
onclick="return popup(this,'examplea')" style="text-decoration: none;">
<asp:Label ID="lblGroundName" runat="server" Text='<%#Eval("GroundName") %>'></asp:Label>
</a>)</span></a></div>
<div class="ft_lt txt_right line_height col14per" style="margin-top: 12px;">
<a class="scrcrd blue_back border_radius10 white relative"
href='<%#Eval("Currentmatch_Id","delete_score_card.aspx?id={0}") %>'
onclick="return popup(this,'examplea')">Scorecard</a>
</div>
<div class="clr">
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
this the .cs code
/////
private void bindRecentMatches()
{
SqlConnection objCon;
SqlCommand objCmd;
string strQuery;
DataSet objDs = new DataSet();
SqlDataAdapter objDa;
int i = 0;
try
{
strQuery = "select_recent_match_by_eventorganizer";
using (objCon = new SqlConnection(ConfigurationManager.ConnectionStrings["sports"].ToString()))
{
objCon.Open();
using (objCmd = new SqlCommand(strQuery, objCon))
{
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@eventorganizer", username);
using (objDa = new SqlDataAdapter(objCmd))
{
i = objDa.Fill(objDs);
if (objDs.Tables[0].Rows.Count > 0)
{
if (grdlistTeam != null)
{
grdlistTeam.DataSource = objDs.Tables[0].DefaultView;
grdlistTeam.DataBind();
}
}
else
{
}
}
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
////////////
protected void grdlistTeam_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdlistTeam.PageIndex = e.NewPageIndex;
bindRecentMatches();
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
How to use LiveView in C# webform to display some fields ver
Product filtering like shopping sites in asp.net?