Solved

Sort & page on custom Gridview itemtemplate?

Posted on 2009-05-19
2
673 Views
Last Modified: 2013-12-17
Hi,
How do i enable the sort and paging if i were to use a customize itemtemplate on a gridview?

Basically i'm putting few information into 1 column, rather than each info on each column as what a default gridview will do (thus the customize itemtemplate). But i just couldn't find a way to enable the paging or sorting.

Any help is greatly appreciated.

PS: Rather than calling the sqldatasource in the gridview web control, i programmatically databind the gridview - datatable.


.aspx page

==========

        <asp:GridView ID="gvwAllMenu" runat="server" AutoGenerateColumns="false" AllowSorting="true" >

            <Columns>

                <asp:BoundField HeaderText="ID" DataField='<%#Eval("menu_info_id")%>' />

                <asp:TemplateField>

                    <HeaderTemplate>

                        Market Place

                    </HeaderTemplate>

                    <ItemTemplate>

                    <table>

                        <tr>

                            <td><%#Eval("menu_info_id")%></td>

                            <td>

                                <%#Eval("title")%><br />

                                <i><%#Eval("summary")%></i>

                            </td>

                        </tr>

                        <tr>

                            <td><%#Eval("created_date")%></td><td> | <%#Eval("created_by")%></td>

                        </tr>

                        <tr>

                            <td>

                                <asp:LinkButton ID="btnView" runat="server" Text="View" 

                                            CommandArgument='<%#Eval("menu_info_id")%>'

                                            CommandName="view" />

                            </td>

                        </tr>

                    </table>

                    </ItemTemplate>

                </asp:TemplateField>

            </Columns>

        </asp:GridView>
 

.aspx.vb page

==============

                gvwAllMenu.AllowSorting = True

                gvwAllMenu.AllowPaging = True

                gvwAllMenu.PageSize = 10
 

                gvwAllMenu.DataSource = objPublicUser.MenuAll()   'Connect to store procedure

                gvwAllMenu.DataBind()

Open in new window

0
Comment
Question by:tangteng78
2 Comments
 

Author Comment

by:tangteng78
ID: 24424430
Btw,  some typo here. Paging is working fine...but i can't get the sorting to work.

PS: The header is not even underline to be clicked on.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24648210
I think you have to provide custom sorting in this scenario.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now