----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: ZuzarAli Message 6 in Discussion Hi Mahesh,<o:p></o:p> .NET Framework does not allow datagrid for Winforms to have paging functionality like what we have in ASP.NET.<o:p></o:p> Still you can achieve this at the DB end where you restrict the number of records and then display the number of records in Datagrid.<o:p></o:p> You can go through this sample SP and then you will understand better.<o:p></o:p> Everytime time you navigate you pass the CurrentPage number and the number of Records you want to show at a time.<o:p></o:p> And this will return you that many records.<o:p></o:p> <o:p> </o:p> Regards,<o:p></o:p> Zuzar L.<o:p></o:p> <o:p> </o:p> <o:p> </o:p> ------------------------------------------------------------------------------------------------------------------<o:p></o:p> Create Procedure dbo.sqlj_GetClientsByPage -- Declare parameters. @CurrentPage As tinyint, @PageSize As tinyint, @TotalRecords As int OUTPUT As -- Turn off count return. Set NoCount On -- Declare variables. Declare @FirstRec int Declare @LastRec int -- Initialize variables. Set @FirstRec = (@CurrentPage - 1) * @PageSize Set @LastRec = (@CurrentPage * @PageSize + 1) -- Create a temp table to hold the current page of data -- Add an ID column to count the records Create Table #TempTable ( ClientId int IDENTITY PRIMARY KEY, Name varchar(50), Balance smallmoney ) --Fill the temp table with the reminders Insert Into #TempTable ( Name, Balance ) Select Name As Name, Balance As Balance From Clients Order By Name --Select one page of data based on the record numbers above Select ClientId, Name, Balance From #TempTable As Clients Where ClientId > @FirstRec And ClientId < @LastRec --Return the total number of records available as an output parameter Select @TotalRecords = Count(*) From Clients<o:p></o:p> <o:p> </o:p> <o:p> </o:p> <o:p> </o:p> <o:p> </o:p> Being guru is not about knowing the answer, but knowing how to search for an answer<o:p></o:p> <o:p> </o:p> ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
