I think this must be a simple thing, and I have searched the forums - but apparently I have completely missed it.
I have a simple RadGrid bound to an ObjectDataSource - the automatic paging / sorting work just fine.
When I add the following ItemCommand code, the actual ItemCommands do work as expected - however, paging and sorting is no longer functional. I see the paging/sorting post back (via firebug) - and what I think is happening is the paging/sorting fire the ItemCommand code, but there is nothing there to handle that. So my question is, what needs to be done to keep the automatic paging/sorting in place, along with the following ItemCommand logic?
Thanks - Kevin
I have a simple RadGrid bound to an ObjectDataSource - the automatic paging / sorting work just fine.
| <telerik:RadGrid ID="rgrdUsers" runat="server" Skin="Web20" AutoGenerateColumns="False" |
| DataSourceID="odsUsers" GridLines="None" AllowSorting="True" AllowPaging="True"> |
| <PagerStyle AlwaysVisible="True" /> |
| <MasterTableView DataSourceID="odsUsers" DataKeyNames="UserID" PagerStyle-AlwaysVisible="True"> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="ViewProfile" ItemStyle-HorizontalAlign="Center" |
| HeaderStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:ImageButton ID="lnkViewProfile" CommandName="ViewProfile" runat="server" ToolTip="View Profile" |
| ImageUrl="~/images/icon_hostusers_16px.gif"></asp:ImageButton> |
| </ItemTemplate> |
| <HeaderStyle HorizontalAlign="Center" Font-Bold="true" /> |
| <ItemStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn UniqueName="ViewAdItems" ItemStyle-HorizontalAlign="Center" |
| HeaderStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:ImageButton ID="lnkViewAdItems" CommandName="ViewAdItems" runat="server" ToolTip="View Ad Items" |
| ImageUrl="~/images/file.gif"></asp:ImageButton> |
| </ItemTemplate> |
| <HeaderStyle HorizontalAlign="Center" Font-Bold="true" /> |
| <ItemStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Username" HeaderText="Username" SortExpression="Username" |
| UniqueName="Username"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" |
| UniqueName="FirstName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName" |
| UniqueName="LastName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Telephone" HeaderText="Telephone" SortExpression="Telephone" |
| UniqueName="Telephone"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CreatedOnDate" DataType="System.DateTime" HeaderText="Created" |
| SortExpression="CreatedOnDate" UniqueName="CreatedOnDate" DataFormatString="{0: M/d/yy h:mm tt}"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LastModifiedOnDate" DataType="System.DateTime" |
| HeaderText="LastActive" SortExpression="LastModifiedOnDate" UniqueName="LastModifiedOnDate" |
| DataFormatString="{0: M/d/yy h:mm tt}"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ExpiryDate" DataType="System.DateTime" HeaderText="Expires" |
| SortExpression="ExpiryDate" UniqueName="ExpiryDate" DataFormatString="{0: M/d/yy h:mm tt}"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn HeaderText="Props/Ads" SortExpression="CountAdItems" |
| UniqueName="CountAdItems" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:Label ID="lblProps" runat="server" Text='<% #Eval("CountAdItems") %>'></asp:Label> |
| / |
| <asp:Label ID="lblAds" runat="server" Text='<% #Eval("CountAdInstances") %>'></asp:Label> |
| </ItemTemplate> |
| <HeaderStyle HorizontalAlign="Center" Font-Bold="true" /> |
| <ItemStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Views/Clicks" SortExpression="CountAdViews" |
| UniqueName="CountAdViews" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:Label ID="lblViews" runat="server" Text='<% #Eval("CountAdViews") %>'></asp:Label> |
| / |
| <asp:Label ID="lblClicks" runat="server" Text='<% #Eval("CountAdClicks") %>'></asp:Label> |
| </ItemTemplate> |
| <HeaderStyle HorizontalAlign="Center" Font-Bold="true" /> |
| <ItemStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="AffiliateName" HeaderText="Affiliate" SortExpression="AffiliateName" |
| UniqueName="AffiliateName"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <PagerStyle AlwaysVisible="True"></PagerStyle> |
| </MasterTableView> |
| </telerik:RadGrid> |
When I add the following ItemCommand code, the actual ItemCommands do work as expected - however, paging and sorting is no longer functional. I see the paging/sorting post back (via firebug) - and what I think is happening is the paging/sorting fire the ItemCommand code, but there is nothing there to handle that. So my question is, what needs to be done to keep the automatic paging/sorting in place, along with the following ItemCommand logic?
| Protected Sub rgrdUsers_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgrdUsers.ItemCommand |
| Dim UserID As Integer = Int32.Parse(e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("UserID")) |
| Select Case e.CommandName |
| Case "ViewProfile" |
| Response.Redirect("~/MyProfile.aspx?UserID=" & UserID) |
| Case "ViewAdItems" |
| Response.Redirect("~/Home.aspx?UserID=" & UserID) |
| End Select |
| End Sub |
Thanks - Kevin