TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajesh Kumar
NA
6
3.8k
Grid View Pagination issue.
Sep 15 2014 1:58 AM
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();
}
Reply
Answers (
1
)
How to use LiveView in C# webform to display some fields ver
Product filtering like shopping sites in asp.net?