Click here to Skip to main content
15,886,562 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends,

I want to append the data to the existing gridview.Can any one solve my problem.
Posted
Comments
Ankur\m/ 19-Mar-13 8:24am    
Client side or server side? And how are you binding it - databound controls or dataset/datatable?
kavithabonala 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/ 19-Mar-13 8:41am    
Can you show us the code of how are you appending the new data?
kavithabonala 19-Mar-13 8:43am    
I uploaded my code
kavithabonala 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

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.
 
Share this answer
 
Comments
kavithabonala 19-Mar-13 8:52am    
in button click i want to append data to the gridview
C#
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);
        }
 
Share this answer
 
v2

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