Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi friends,
 
I want to append the data to the existing gridview.Can any one solve my problem.
Posted 19-Mar-13 3:17am
Comments
Ankur\m/ at 19-Mar-13 8:24am
   
Client side or server side? And how are you binding it - databound controls or dataset/datatable?
kavithabonala at 19-Mar-13 8:33am
   
Actually I have binded some data to the grid view (5 records) and I took one button in that button click i want to append 5 more records to the grid view and again button click i want next 5 more records to append the gridview.
 
actually i done it but first it displays 1 to 5 records and again i want to append 6 to 10 records but it displays first time 1to 5 abd next 6 to 10 but it is not appending the records.
Ankur\m/ at 19-Mar-13 8:41am
   
Can you show us the code of how are you appending the new data?
kavithabonala at 19-Mar-13 8:43am
   
I uploaded my code
kavithabonala at 19-Mar-13 8:44am
   
MyProcedure
 

ALTER PROCEDURE [dbo].[USP_GetGamesPaging]
(
@XmlDoc xml =null
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
 
-- Insert statements for procedure here
DECLARE @PageNum INT,
@PageSize INT

SELECT @PageNum=C.value('(PageNum)[1]','INT'),
@PageSize=C.value('(PageSize)[1]','INT')
FROM @XmlDoc.nodes('Adduserdetails') AS T(C);
WITH samplegames as
(
 
SELECT ROW_NUMBER() OVER(ORDER BY GameId ASC) AS Row,GameId,Game from TblGames
)
SELECT
(
SELECT * from samplegames where Row between (@PageNum-1)*(@PageSize+1) and @PageNum*@PageSize
FOR XML PATH('Adduserdetails'),TYPE
)
FOR XML PATH (''),ROOT('AdduserdetailsInfoByXmls')
END
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you are using any datasource for gridview then just update the datasource and call gridview's DataBind() method.
 
Or you can use Rows.Add() method of gridview.
  Permalink  
Comments
kavithabonala at 19-Mar-13 8:52am
   
in button click i want to append data to the gridview
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BindGrid(1, 5);
                }
            }
            catch
            {
                throw;
            }
        }
        public void BindGrid(int PageNum, int PageSize)
        {
            XmlDocument xml = null;
            Adduserdetails obj_Adduserdetails = new Adduserdetails();
            AdduserdetailsList obj_AdduserdetailsList = new AdduserdetailsList();
            try
            {
 
                obj_Adduserdetails.PageNum = PageNum;
                obj_Adduserdetails.PageSize = PageSize;
                xml = obj_Adduserdetails_BAL.Get(obj_Adduserdetails, ReturnType.Get);
                obj_AdduserdetailsList = _Obj_iDsignBAL.DeserializeFromXml<adduserdetailslist>(xml);
                _Obj_iDsignBAL.FillGridView(_Obj_iDsignBAL.ConvertListToDataSet<adduserdetails>(obj_AdduserdetailsList.items).Tables[0], grdGames);
            }
            catch
            {
                throw;
            }
 
        }
 
        protected void btnNext_Click(object sender, EventArgs e)
        {
            BindGrid(2, 5);
        }
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 19 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100