Thanks a lot for your reply.
Ok the biggest problem i have with what you are suggesting is the "In your DataGridEx's PreRender method, you could determine what links to pages you'd like to display (eg First, Prev, 2, 3, 4 .... etc) and add them as LinkButton's to the placeholder control 'pager'. Hook up the events and you are away.".
As per your suggestion i have put together the below sub which should be able to handles the construction of the paging.
Protected Sub CreatePaging(ByVal objPlaceHolder As PlaceHolder)
Dim PagerFirstImg As New HyperLink
Dim PagerLastImg As New HyperLink
Dim PagerPreviousImg As New HyperLink
Dim PagerNextImg As New HyperLink
Dim PagerNumberPosA As New HyperLink
Dim PagerNumberPosB As New HyperLink
Dim PagerNumberPosC As New HyperLink
Dim PagerNumberPosD As New HyperLink
Dim PagerNumberPosE As New HyperLink
If _intPageCurrentPage > 0 Then
'Adds the first image
PagerFirstImg.ImageUrl = objPlaceHolder.ResolveUrl(
..... 'Event code needs to be added in here
'Adds the prvious image
PagerPreviousImg.ImageUrl = objPlaceHolder.ResolveUrl(
..... 'Event code needs to be added in here
End If
If _intPageRecordEnd < _intPageTotalRecordCount Then
'Adds the first image
PagerNextImg.ImageUrl = objPlaceHolder.ResolveUrl(
..... 'Event code needs to be added in here
'Adds the prvious image
PagerLastImg.ImageUrl = objPlaceHolder.ResolveUrl(
..... 'Event code needs to be added in here
End If
....................... 'Code to constuct the PagerNumberPosX controls
'Sets it to the place holder
....................... 'Add in the additional HTML and Bind all the controls the the placeholder
End Sub
Now i am pretty sure that i can hook up the events and can write the code to construct the PagerNumberPosX control, the only problem i have at the moment is how to add in my formatting HTML. The HTML that is constructed for each of the controls should be something like the following:
PagerFirstImg - <a href="javascript:...."><im
PagerPreviousImg - <a href="javascript:...."><im
PagerNumberPosA - <a href="javascript:....">3</
PagerNumberPosB - <a href="javascript:....">4</
PagerNumberPosC - <a href="javascript:....">5</
PagerNumberPosD - <a hef="javascript:.....">6</
PagerNumberPosE - <a href="javascript:....">7</
PagerNextImg - <a href="javascript:...."><im
PagerLastImg - <a href="javascript:...."><im
I need to turn it into to something like this (with the added href offcourse):
<div class="navPagging"><img src="image/buttonfirst.jpg
<img src="image/buttonprev.jpg"
<span class="selected">5</span> 6 7 </div><img src="image/buttonnext.jpg"
<img src="image/buttonlast.jpg"
Now if i understand the '.Controls.Add(....)' can't just plain HTML inserted into it. So i need a what of binding the objects all together, with the necessary HTML and i really dont want to go about it by creating a whole heap of nested PlaceHolder's.
Lastly i am just wondering why you would suggest creating a user control over a CustomDataGrid class? It's just that atm i am not bound to using a class, but i just thought that using a class would give me more functionality.
Thanks
ant
Main Topics
Browse All Topics





by: asdaveyPosted on 2006-04-15 at 04:11:53ID: 16459920
Hmmm.
/>
TagName="DataGridEx" src="~/usercontrols/datagr idex.ascx" %>
runat="server"/>
I make this comment fully aware of not knowing exactly what situations you've tried and what design tradeoff decisions you've already made.
I would strongly encourage you to try and implement your solution using a UserControl. Tonight I'm actually working on a very similar control (but in .Net 2 which has the GridView which is very easy to work with). By using a UserControl, you can create a composite control. Basically you'd be hooking up your custom rendered pager with .Net 1.1's DataGrid control.
In the UserControl (let's call it DataGridEx) the markup could look something like:
<div>
<asp:datagrid runat="server" id="datagrid" autogeneratecolumns="true"
<asp:placeholder runat="server" id="pager"/>
</div>
In your DataGridEx's PreRender method, you could determine what links to pages you'd like to display (eg First, Prev, 2, 3, 4 .... etc) and add them as LinkButton's to the placeholder control 'pager'. Hook up the events and you are away.
On the page that you would like to have your DataGridEx appear, the page would look like:
<%@ Register TagPrefix="MyUserControls"
<myusercontrols:datagridex
If you've not had any previous experience with UserControls I'd suggest tackling something a little simpler for your first attemp (a login page or something).
If you've already looked down this path and have made the decision that a Server control is the way that you have to go, I'd suggest inhieriting from WebControl instead of Page since the Page control is very much targetted to rendering pages and not controls.
HIH
Andy