This is a migrated thread and some comments may be shown as answers.

Getting Invalid postback or callback argument when sorting

4 Answers 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PaulMrozowski
Top achievements
Rank 1
PaulMrozowski asked on 12 Jun 2009, 07:53 PM
I'm using a RadGrid control along with the RadToolTipManager control. If you click on the row header it sorts correctly. if you click on it again, it resorts in the opposite direction. However, if you click on the up/down resort image instead it fails with an "invalid postback or callback argument" error.

I've tried explicitly setting the sort expression, but it doesn't seem to help. Here's a sample of how it's configured:

<telerik:RadGrid ID="grdScoreCard" runat="server"  
        onneeddatasource="grdScoreCard_NeedDataSource" EnableViewState="False" 
        OnItemCommand="grdScoreCard_ItemCommand" 
        AutoGenerateColumns="False" GridLines="None"    
        onitemdatabound="grdScoreCard_ItemDataBound" AllowSorting="True"
        <headercontextmenu enabletheming="True"
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </headercontextmenu> 
        <mastertableview showfooter="True" AllowMultiColumnSorting="true" AllowSorting="true"
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns>     
                <telerik:GridTemplateColumn> 
                    <ItemTemplate> 
                        <asp:HyperLink ID="lnkInfo" Text="Details" ToolTip="Info" NavigateUrl="#" runat="server"></asp:HyperLink> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn>   
<telerik:GridBoundColumn DataField="AvgContractAmount" DataFormatString="{0:c}" 
                    HeaderText="Avg. Contract $"  
                    SortExpression="AvgContractAmount" 
                    UniqueName="colAvgContractAmount"  Aggregate="Sum" FooterAggregateFormatString="{0:0,0}"
                    <FooterStyle HorizontalAlign="Right" /> 
                    <ItemStyle HorizontalAlign="Right" /> 
                </telerik:GridBoundColumn>           

Here's what the various bound events look like:

        protected void btnGenerate_Click(object sender, EventArgs e) 
        {            
            this.grdScoreCard.Rebind(); 
        } 
 
        protected void grdScoreCard_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            if (e.CommandName == "Sort" || e.CommandName == "Page"
            { 
                this.RadToolTipManager1.TargetControls.Clear(); 
            } 
 
        } 
 
        protected void grdScoreCard_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            this.Generate(); 
        } 
 
        protected void Generate() 
        { 
            DataTable table = this.GenerateData();          
            this.grdScoreCard.DataSource = table; 
        } 
 
        protected void grdScoreCard_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item.ItemType == Telerik.Web.UI.GridItemType.Item || e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem) 
            { 
                HyperLink link = e.Item.FindControl("lnkInfo"as HyperLink; 
                if (link != null
                { 
                    DataRowView view = (DataRowView)e.Item.DataItem; 
                    this.RadToolTipManager1.TargetControls.Add(link.ClientID, view.Row["LocationID"].ToString(), true); 
                } 
            } 
 
            if (e.Item is Telerik.Web.UI.GridDataItem) 
            {                 
                Telerik.Web.UI.GridDataItem item = e.Item as Telerik.Web.UI.GridDataItem; 
                if (item != null
                { 
                    int index = e.Item.ItemIndex + 1; 
                    item["colRank"].Text = index.ToString(); 
                }                 
            } 
          
            if (e.Item is Telerik.Web.UI.GridFooterItem) 
            { 
                DataTable table = this.grdScoreCard.DataSource as DataTable; 
                this.GenerateFooter(e, table); 
            } 
        } 


Any ideas about why this isn't working?

4 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 16 Jun 2009, 07:40 AM
Hi PaulMrozowski,

This is a known issue with RadGrid when it has its ViewState disabled. To fix it, you need to set RadGrid's ViewState back on, and disable a parent control's ViewState instead.

Sincerely yours,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
PaulMrozowski
Top achievements
Rank 1
answered on 16 Jun 2009, 05:09 PM
Wow, sometimes it takes a second pair of eyes to see what's in front of your face. I caught that issue during searching some of the messages here but didn't realize I had it disabled in my own code. Thanks.
0
turkush .
Top achievements
Rank 1
answered on 12 Nov 2009, 07:47 AM

The rad grid sorting is working fine But when i do click on Sort image it gives me exception:

Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


BUT I ENCOUNTERED IT ONLY IN FIREFOX. IN IE ITS WORKING FINE .
0
Iana Tsolova
Telerik team
answered on 18 Nov 2009, 02:45 PM
Hi turkush,

Could you please elaborate a bit on your scenario and share your grid declaration as well? I will try replicating the issue locally and turn back to you with my findings.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
PaulMrozowski
Top achievements
Rank 1
Answers by
Veli
Telerik team
PaulMrozowski
Top achievements
Rank 1
turkush .
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or