Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

reusing a gridview pager template

Avatar of andieje
andieje asked on
ASP.NET
8 Comments1 Solution11225 ViewsLast Modified:
Hi

I have a gridview that has a custom pager template. I also have some code in the page that creates some numeric links dynamically and adds them to the pager template and handles their events.

I would like to encapsulate this into a control so that I can reuse the paging functionality but change the columns the grid displays on different pages. I haven't got a clue how to do this. Please could you advise where I would begin

Here is the template. I know I could make this into a template class if that helps

<asp:GridView ID="GridView1" runat="server">

<PagerTemplate>

<tr>

<td style="padding-left:10px;">

<asp:ImageButton ID="imgFirst" runat="server" CommandName="Page" CommandArgument="First" ImageUrl="~/Images/first_grey.gif" Height="14px" Width="16px" /></td>

<td>

<asp:ImageButton ID="imgPrev" runat="server" CommandName="Page" CommandArgument="Prev" ImageUrl="~/Images/prev_grey.gif" Height="14px" Width="11px" /></td>

<td style="padding-right: 3px; padding-left: 3px;"><span id="pnlNumberLinks" runat="server"></span></td>

<td>

<asp:LinkButton ID="lnkNext" runat="server" CommandName="page" CommandArgument="Next" CausesValidation="false" Text="Next" />

<asp:ImageButton ID="imgNext" runat="server" CommandName="Page" CommandArgument="Next" ImageUrl="~/Images/next_grey.gif" Height="14px" Width="11px" /></td>

<td> <asp:ImageButton ID="imgLast" runat="server" CommandName="Page" CommandArgument="Last" ImageUrl="~/Images/last_grey.gif" Height="14px" Width="16px" /></td>

</tr>

</PagerTemplate>

</asp:GridView>

 

Then in the page behind I have code for creating the links and responding to link clicks. For example here is a function for handling the click of a link button



Sub NumericNav_OnCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)

CurrentPageNumber = e.CommandName

BindGrid()

End Sub

 

If I put this grid into a user control, how would i be able to change the columns that the grid displays on different pages? Do I have to do something more complicated than a user control?

 

thanks a lot

andrea
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers