Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everyone ??

Am new to Programming, Please help me.

I have a GRIDVIEW on my Webpage. i have large number of data in database and finally displayed data in Gridview. and also i gave paging in it.

So, when i click on Paging numbers 1,2,3,4......it should load. JUST IT should Show loading image and 2nd papge data must be displayed when user clicks 2nd page.


Please help me, Thanks.
Posted

What you speak of is called: "Load on demand" feature. For this, you need to implement Custom Paging.

Following articles will help explain in implementation:
GridView Custom Paging[^]
Custom Paging for GridView[^]
Custom Paging in ASP.NET 2.0 with SQL Server 2005[^]

Try!
 
Share this answer
 
Hi,
A event called PageIndexChanging is there with gridview. You can use that for the paging. Here is a sample code:
C#
protected void gvArticals_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    try
    {
       gvArticals.DataSource = dtArticle;//dtArticle is your datasource
       gvArticals.PageIndex = e.NewPageIndex;
       gvArticals.DataBind();
    }
    catch (Exception ex)
    {
       //Handle the exception here
    }
}

Yes, now you want a loading image for gridview while paging. Put your gridview inside asp:UpdatePanel and asp:UpdateProgress. Example:
ASP.NET
<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
</asp:scriptmanager>
<asp:updateprogress id="updProgress" xmlns:asp="#unknown">
    AssociatedUpdatePanelID="UpdatePanel1"
    runat="server">
    <progresstemplate>            
        <img alt="progress" src="images/progress.gif" />
           Processing...            
    </progresstemplate>
</asp:updateprogress>

<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
    <contenttemplate>
         <asp:gridview id="gvArticals" runat="server"></asp:gridview>
    </contenttemplate>
</asp:updatepanel>   


Note:One instance of ScriptManager is require to run the ajax controls.
For positioning the image in the gridview's center refer the following link:
http://www.w3schools.com/cssref/pr_class_position.asp[^]
All the best.
--Amit
 
Share this answer
 
v2
Comments
Software Engineer 892 15-Jul-12 3:00am    
Boss, I need some help from you.

what you have gave me , its working fine. BUT

I need to show this loading image in centre of GRIDVIEW. Please help.
_Amy 15-Jul-12 3:26am    
Make the style class in css and set the position of the "Loading Image" in the center of the grid.
Software Engineer 892 15-Jul-12 3:45am    
Please tell me, am not familiar with CSS. Please can u ?
_Amy 15-Jul-12 6:46am    
See my updated answer. I'hv given a link for css positioning..
_Amy 15-Jul-12 6:47am    
Please see my updated answer..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900