Project : ASP.NET 3.5
Server : SQL Server 2008
One of the page in the project is used to list all log entry(including errors, information etc). So the there will be huge amount of records to list.
I would like to create a ‘Pager’ user control so that I can use it everywhere. I cannot use pager provided by ASP.NET, because the pager may have lot of additional functionality(such as SelectAllRecords etc).
So for ‘LogListPage’, I will call GetLogInfo() function to get the data.
for ‘OrderListPage’, I will call GetOrderInfo() etc…
For each function, I will pass ‘PageSize’ and ‘CurrentPage’ so that I can effectively select required number of record(instead of selecting all records).
So my question is, how can I create the control as a general control ? Because for each page, I have to call different functions. I can refer to list page’s gridview by creating a public property in user control. But if I click, ‘First’, ‘Previous’,’Next’, or ‘Last’ links of the user control, I have to connect to database and select records. Can I pass the function name to the user control and execute the function, then bind the grid?
First of all: start from HERE
then, I can suggest to create a level of abstraction between the paginator control and the database. If you define a general mode for all the page, you can bind your paginator to a datasource that does not depend on the database.
We are talking about log, so abstract a log entry should be not so difficult.
You should also think to extend the control as detailed HERE