ItemCommand Event

2 posts, 0 answers
  1. Neil
    Neil avatar
    50 posts
    Member since:
    Mar 2009

    Posted 04 Nov 2012 Link to this post

    I have a RadGrid that I added an ItemCommand event to. The UI uses Twitter Bootstrap to open a modal window, this window has a textbox and a send button with a command name and command argument.  When I click the button, I get :

    Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.




    ASPX:
    <telerik:RadGrid ID="MyGrid" OnItemCommand="MyGrid_ItemCommand"
            Skin="Sitefinity" AllowSorting="True" AutoGenerateColumns="false" AllowPaging="True"
            PageSize="10" runat="server" GridLines="None" Width="100%">
            <PagerStyle EnableSEOPaging="true" SEOPagingQueryStringKey="p" Mode="NumericPages">
            </PagerStyle>
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%#Eval("Name")%></ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderStyle-Font-Bold="true" HeaderText="Progress">
                        <ItemTemplate>
                            <div class="progress progress-success progress-striped" style="position: relative;
                                top: 10px;">
                                <asp:Panel runat="server" ID="progressBar" EnableViewState="false" CssClass="bar progress">
                                    <%#Eval("Complete")%>
                                    /
                                    <%#Eval("TotalCount")%>
                                </asp:Panel>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderStyle-Font-Bold="true" HeaderText="Manage" ItemStyle-Width="220px">
                        <ItemTemplate>
                            <div class="btn-group">
                                <asp:HyperLink ID="matchLink" CssClass="btn" runat="server" Style="color: #333 !important;"
                                    Text="<i class='icon-check'></i> Match" />
                                <button class="btn dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><a href="#message" data-toggle="modal"><i class='icon-envelope-alt'></i>Send Message</a></li>
                                    <li>
                                        <asp:LinkButton ID="downloadLinks" runat="server" Text="<i class='icon-download-alt'></i> Download Data" /></li>
                                </ul>
                            </div>
                            <!-- Modal -->
                            <div id="message" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                                aria-hidden="true">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                        ×</button>
                                    <h3 id="myModalLabel">
                                        Send Message</h3>
                                </div>
                                <div class="modal-body">
                                        <asp:TextBox TextMode="MultiLine" ID="messageTextBox" Width="500px" placeholder="Type your message here…"
                                            runat="server" Rows="10"></asp:TextBox>
                                     
                                </div>
                                <div class="modal-footer">
                                    <button class="btn" data-dismiss="modal" aria-hidden="true">
                                        Cancel</button>
                                    <asp:Button ID="sendMessageButton" CommandName="SendMessage" CommandArgument='<%#Eval("Id")%>'
                                        CssClass="btn btn-primary" Text="Send" runat="server" />
                                </div>
                            </div>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

    Code-behind:
    protected void MyGrid_ItemCommand(object sender, GridCommandEventArgs e)
            {
                // code
            }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Nov 2012 Link to this post

    Hi,

    Unfortunately I canot replicate the error at my end. After inspecting your code I suppose you are binding the grid in page load. Make sure that you are using advanced data binding using its NeedDataSource event to bind the grid. Hope this helps.

    Thanks,
    Shinu.
Back to Top