Telerik RadGrid问题:按钮单击时没有显示SelectedItems,但选择的项目很少

时间:2014-07-02 15:03:44

标签: webforms telerik rad-controls

我的aspx页面上有两个RadGrids,并使用一个搜索TextBox来搜索RadGrid中的项目。 点击一个按钮,所选项目将被转移到其他网格。

问题是当我使用特定关键字搜索项目,然后从RadGrid中选择项目并单击按钮。不执行任何操作,并且在代码中,它显示没有选择任何数据项。然后,如果我再次从搜索列表中选择并单击按钮,它就可以正常工作。

   function requestStart(sender, args) {
        if (args.get_eventTarget().indexOf("ButtonPrint") > 0 
            ||
            args.get_eventTarget().indexOf("ButtonSelect") > 0
            )
            args.set_enableAjax(false);
    }


      <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="EnrollmentPanel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="EnrollmentPanel"      LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
       <telerik:AjaxSetting AjaxControlID="ButtonEnroll">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
</telerik:RadAjaxManagerProxy>

      <telerik:RadGrid ID="EnrollmentGrid" runat="server" Width="100%" GridLines="None"
            AllowPaging="True" ShowStatusBar="true" AutoGenerateColumns="false" DataSourceID="CourseCreditDS"
            OnItemCommand="EnrollmentGrid_ItemCommand" OnItemDataBound="EnrollmentGrid_ItemDataBound">
            <MasterTableView DataKeyNames="pid" CommandItemDisplay="None">
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="20px" />
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="<%$ Resources: Manager, EditCredit %>"
                        Visible="false" />


                    <telerik:GridTemplateColumn UniqueName="AssignedColumn" Visible="false" HeaderStyle-Width="60px">
                        <ItemTemplate>
                            <asp:Image runat="server" ImageUrl="~/Contents/Images/tick.gif" ToolTip="<%$ Resources: Manager, SessionAlreadyEnrolled %>" Visible='<%# Eval("enrolled").ToString() == "Y" %>' />
                            <asp:Image runat="server" ImageUrl="~/Contents/Images/error.gif" ToolTip="<%$ Resources: Manager, SessionAlreadyEnrolledOther %>" Visible='<%# Eval("already_assigned").ToString() == "Y" %>' />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridHyperLinkColumn HeaderText="<%$ Resources: Manager, StudentId %>" DataTextField="pid"
                        DataNavigateUrlFields="pid" DataNavigateUrlFormatString="../Reporting/PivotView.aspx?id={0}"
                        SortExpression="pid" Target="_blank" />
                    <telerik:GridHyperLinkColumn HeaderText="<%$ Resources: Manager, Name %>" DataTextField="name"
                        DataNavigateUrlFields="pid" DataNavigateUrlFormatString="../Reporting/PivotView.aspx?id={0}"
                        SortExpression="lname" Target="_blank" />
                    <telerik:GridBoundColumn HeaderText="<%$ Resources: Manager, Division %>" DataField="div_name"
                        SortExpression="div_name" />
                    <telerik:GridTemplateColumn UniqueName="ResultColumn" HeaderText="<%$ Resources: Manager, Result %>"
                        Visible="false">
                        <ItemTemplate>
                            <asp:Literal ID="ResultText" runat="server" Text="<%$ Resources: Manager, EmptyDataText %>" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn UniqueName="CapIdColumn" HeaderText="<%$ Resources: Manager, CapId %>"
                        DataField="ot1" SortExpression="ot1" ConvertEmptyStringToNull="true" EmptyDataText="<%$ Resources: Manager, EmptyDataText %>"
                        Visible="false" />

                    <telerik:GridTemplateColumn UniqueName="AttachColumn" Visible="false" HeaderText="Attachment">
                        <ItemTemplate>
                            <table>
                                <tr>

                                    <td>
                                        <telerik:RadAsyncUpload ID="CCFileUploader"    runat="server" PostbackTriggers="btnUploadPost" OnFileUploaded="CCFileUploader_FileUploaded" OnClientFileUploaded="CCFileUploader_ClientFileUploaded" UploadedFilesRendering="BelowFileInput" />
                                    </td>
                                    <td>
                                        <asp:Button ID="btnUploadPost" runat="server" CausesValidation="false" Text="hidden" Style="display: none" /></td>
                                    <td>
                                        <asp:LinkButton ID="CCExistingUploadsLink" runat="server" Text="<%$ Resources: Manager, NoExistingAttachments %>" Enabled="false" Style="text-decoration: none; color: #769e1a;" />
                                        <asp:HiddenField ID="CCPid" runat="server" Visible="false" Value='<%# Eval("pid")%>' />
                                    </td>

                                </tr>
                            </table>



                        </ItemTemplate>

                    </telerik:GridTemplateColumn>

                </Columns>
                <EditItemStyle CssClass="EditedItem" />
                <EditFormSettings UserControlName="~/Courses/Template/CourseCredit.ascx" EditFormType="WebUserControl">
                    <FormStyle BackColor="White" />
                </EditFormSettings>

            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
            </ClientSettings>
            <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                <Pdf PageHeight="297mm" PageWidth="210mm" PageTitle="Training Session" />
            </ExportSettings>
        </telerik:RadGrid>


          <telerik:RadGrid ID="EnrollListGrid" runat="server" Width="100%" GridLines="None" AllowPaging="true" PageSize="10" ShowStatusBar="true" AllowMultiRowSelection="true" AutoGenerateColumns="false" OnDetailTableDataBind="EnrollListGrid_DetailTableDatabind"
            OnNeedDataSource="EnrollListGrid_OnNeedDataSource" OnPreRender="EnrollListGrid_OnPreRender">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView AllowMultiColumnSorting="true" DataKeyNames="listname">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="pid" Name="DetailList">
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="20px">
                                <HeaderStyle Width="20px" />
                            </telerik:GridClientSelectColumn>
                            <telerik:GridTemplateColumn UniqueName="AssignedColumn" Visible="false" HeaderStyle-Width="60px">
                                <ItemTemplate>
                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Contents/Images/tick.gif" ToolTip="<%$ Resources: Manager, SessionAlreadyEnrolled %>" Visible='<%# Eval("enrolled").ToString() == "Y" %>' />
                                    <asp:Image ID="Image2" runat="server" ImageUrl="~/Contents/Images/error.gif" ToolTip="<%$ Resources: Manager, SessionAlreadyEnrolledOther %>" Visible='<%# Eval("already_assigned").ToString() == "Y" %>' />
                                </ItemTemplate>
                                <HeaderStyle Width="60px" />
                            </telerik:GridTemplateColumn>
                            <telerik:GridHyperLinkColumn HeaderText="<%$ Resources: Manager, StudentId %>" DataTextField="pid"
                                DataNavigateUrlFields="pid" DataNavigateUrlFormatString="../Reporting/PivotView.aspx?id={0}"
                                SortExpression="pid" Target="_blank" />
                            <telerik:GridHyperLinkColumn HeaderText="<%$ Resources: Manager, Name %>" DataTextField="name"
                                DataNavigateUrlFields="pid" DataNavigateUrlFormatString="../Reporting/PivotView.aspx?id={0}"
                                SortExpression="lname" Target="_blank" />
                            <telerik:GridBoundColumn HeaderText="<%$ Resources: Manager, Division %>" DataField="div_name"
                                SortExpression="div_name" />

                            <telerik:GridBoundColumn UniqueName="CapIdColumn" HeaderText="<%$ Resources: Manager, CapId %>"
                                DataField="ot1" SortExpression="ot1" ConvertEmptyStringToNull="true" EmptyDataText="<%$ Resources: Manager, EmptyDataText %>" />
                        </Columns>


                        <EditItemStyle CssClass="EditedItem" />
                        <EditFormSettings UserControlName="~/Courses/Template/CourseCredit.ascx" EditFormType="WebUserControl">
                            <FormStyle BackColor="White" />
                        </EditFormSettings>

                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <%--<telerik:GridClientSelectColumn UniqueName="ClientSelectList" ></telerik:GridClientSelectColumn>--%>
                    <%--<telerik:GridBoundColumn UniqueName="EnrollListID" HeaderText="Enroll List ID" DataField="listid"></telerik:GridBoundColumn>--%>
                    <%--<telerik:GridEditCommandColumn UniqueName="ViewListItems" EditText="View List Items"  ></telerik:GridEditCommandColumn>--%>
                    <telerik:GridBoundColumn UniqueName="EnrollListName" HeaderText="Enroll List Name" DataField="listname"></telerik:GridBoundColumn>
                </Columns>

            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
                <%--<ClientEvents OnRowSelecting="EnrollListGrid_OnRowSelecting" />--%>
            </ClientSettings>
        </telerik:RadGrid>

如果你需要背后的代码,请告诉我。

1 个答案:

答案 0 :(得分:0)

尝试将绑定源(我认为它是已过滤的网格)ajaxify到绑定目标(第二个网格)。

<telerik:AjaxSetting AjaxControlID="EnrollmentGrid">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="EnrollListGrid" />
    </UpdatedControls>
</telerik:AjaxSetting>

如果有帮助,请告诉我。否则我真的需要一个更简单的代码工作版本......