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
kieky bouvier
NA
58
83.4k
Gridview paging not working...
Mar 27 2011 10:59 AM
i have problem with gridview,
gridview paging not working
.. i feel so confused about it. because i think i already using the right code.this is my code :
detail.aspx
<asp:UpdatePanel ID="UpdatePanel_Main" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView_Main" ClientIDMode="Static" AutoGenerateColumns="false"
DataKeyNames="IdVersi" AllowPaging="true" AllowSorting="true" Width="97%" BorderWidth="1"
OnSelectedIndexChanged="GridView_Main_SelectedIndexChanged" OnSorted="GridView_Main_Sorted"
OnPageIndexChanged="GridView_Main_PageIndexChanged" OnPageIndexChanging="GridView_Main_PageIndexChanging"
runat="server" PageSize="4">
<EmptyDataTemplate>
<div class="EmptyDataMessage">
<asp:Label ID="Label_GridView_Empty" runat="server" Text="Data tidak ditemukan."></asp:Label>
</div>
</EmptyDataTemplate>
<HeaderStyle CssClass="GridviewHeader" />
<SelectedRowStyle CssClass="GridviewSelect" />
<AlternatingRowStyle CssClass="GridviewAlternate" />
<Columns>
<asp:TemplateField HeaderText="No Versi" ItemStyle-CssClass="GridviewItem" ItemStyle-VerticalAlign="Top"
ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="15%" ItemStyle-Wrap="false">
<ItemTemplate>
<asp:LinkButton ID="LinkButton_Select" CommandName="Select" runat="server"><%# Eval ("NoVersi") %></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Notes" HeaderText="Catatan" ItemStyle-CssClass="GridviewItem"
HeaderStyle-Width="30%" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="ModifiedOn" HeaderText="Diubah tanggal" ItemStyle-CssClass="GridviewItem"
HeaderStyle-Width="30%" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Type" HeaderText="Type" ItemStyle-CssClass="GridviewItem"
HeaderStyle-Width="30%" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Size" HeaderText="Size" ItemStyle-CssClass="GridviewItem"
HeaderStyle-Width="25%" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Aksi" ItemStyle-CssClass="GridviewItem" ItemStyle-VerticalAlign="Top"
ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20%" ItemStyle-Wrap="false">
<ItemTemplate>
<a href='<%# Eval ("UrlFile") %>'>Download</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NumericFirstLast"/>
<PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" ForeColor="#80A0CF" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
detail.aspx.cs
protected void GridView_Main_DataBind(int NewPageIndex)
{
id_document = Convert.ToInt32(Request.QueryString[0]);
DMSDataAccess db = new DMSDataAccess();
var versi = db.DMSDataContext.Versis.Select(p => p).Where(p => p.IdDokumen == id_document);
GridView_Main.PageSize = itemPerPage;
GridView_Main.PageIndex = NewPageIndex;
GridView_Main.DataSource = versi;
GridView_Main.DataBind();
}
protected void GridView_Main_SelectedIndexChanged(object sender, EventArgs e)
{
Button_Update.Visible = false;
Button_UpdateKepemilikan.Visible = false;
Label_Modal_Title.Text = "Properties";
MultiView_Content.SetActiveView(View_Versi);
try
{
id_document = Convert.ToInt32(Request.QueryString[0]);
string id = GridView_Main.SelectedValue.ToString();
DMSDataAccess db = new DMSDataAccess();
var doc = db.DMSDataContext.Dokumens.Select(p => p).Where(p => p.IdDokumen.Equals(id_document)).FirstOrDefault();
var versi = db.DMSDataContext.Versis.Select(p => p).Where(p => p.IdVersi.Equals(id)).FirstOrDefault();
string id_category = Convert.ToString(doc.IdCategory);
Label_Value_VersiJudul.Text = doc.JudulDokumen;
Label_Value_VersiType.Text = versi.Type;
Label_Value_VersiSize.Text = Convert.ToString(versi.Size) + " Kb";
Label_Value_VersiVersi.Text = Convert.ToString(versi.NoVersi);
Label_Value_VersiAuthor.Text = GetNamaDosen(versi.UserName);
Label_Value_VersiTanggal.Text = Convert.ToString(versi.ModifiedOn);
Label_Value_VersiCategory.Text = GetNamaCategory(id_category);
Label_Value_VersiDeskripsi.Text = doc.Deskripsi;
if (versi.Notes != null)
{
Label_Value_VersiNotes.Text = versi.Notes;
}
else { Label_Value_VersiNotes.Text = "-"; }
}
catch { }
UpdatePanel_Panel_Modal.Update();
this.MPE.Show();
}
protected void GridView_Main_Sorted(object sender, EventArgs e)
{
GridView_Main_DataBind(GridView_Main.PageIndex);
GridView_Main.SelectedIndex = -1;
}
protected void GridView_Main_PageIndexChanged(object sender, EventArgs e)
{
GridView_Main_DataBind(GridView_Main.PageIndex);
GridView_Main.SelectedIndex = -1;
}
protected void GridView_Main_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView_Main_DataBind(e.NewPageIndex);
}
whats wrong? can u help me?
Reply
Answers (
4
)
how to print particular page area in web application usin c#2008
How to bind an arraylist's data to GridView control