Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii ,

I have one gridview ,where we can select only one row at a time.
I have one button outside the gridview and want to get records of selected rows of gridview.

I have used callback control to get this records using getselectedvalues methd but not getting any values

XML
<dx:ASPxPopupControl ID="pcPendingApprovals" runat="server" RenderMode="Lightweight" ClientInstanceName="pcPendingApprovals"
    CloseAction="CloseButton" Modal="true" ShowCloseButton="true" Width="700px"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
    HeaderText="Plans Awaiting Approval" PopupAnimationType="Fade" EnableViewState="False">
    <ContentCollection>
        <dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server">
            <dx:ASPxGridView ID="gvPendingApprovalList" ClientInstanceName="gvPendingApprovalList" Width="100%"
                KeyFieldName="PlanId" runat="server" AutoGenerateColumns="false" DataSourceID="odsPendingApprovalList"
                 SettingsBehavior-AllowSelectSingleRowOnly="true">
                <Columns>
                    <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                    </dx:GridViewCommandColumn>

                    <dx:GridViewDataTextColumn FieldName="EmployeeName" Caption="Employee Name" Width="10%" VisibleIndex="1"></dx:GridViewDataTextColumn>
                    <dx:GridViewDataDateColumn FieldName="Month" Caption="Month" SortOrder="Descending" Width="10%" VisibleIndex="2"></dx:GridViewDataDateColumn>
                    <dx:GridViewDataTextColumn FieldName="Year" Caption="Year" Width="20%" VisibleIndex="3"></dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="ApproveStatus" Caption="Submitted" VisibleIndex="3"></dx:GridViewDataTextColumn>
                </Columns>
                <SettingsPager PageSize="5">
                </SettingsPager>
                <Settings ShowStatusBar="Hidden" ShowFilterRow="false" ShowGroupPanel="false" />
                <SettingsDataSecurity AllowDelete="False" AllowEdit="False" AllowInsert="False" />
            </dx:ASPxGridView>
            <asp:ObjectDataSource ID="odsPendingApprovalList" runat="server" TypeName="Assistpro.AssistproCRM.Presenter.PlanPresenter"
                SelectMethod="GetDirectReporteesSubmittedPlansByUserId" OnObjectCreating="odsPendingApprovalList_ObjectCreating"></asp:ObjectDataSource>
            <input type="button" name="btnLoadMe" id="btnLoadMe" value=" Load Me " />
            <dx:ASPxButton ID="btnLoad" runat="server" Text="Load Plan" AutoPostBack="false">
                <ClientSideEvents Click="checkMe(this)" />
            </dx:ASPxButton>
            <dx:ASPxButton ID="btnCancelList" runat="server" Text="Cancel">
                <ClientSideEvents Click="CancelPendingApprovalList" />
            </dx:ASPxButton>
        </dx:PopupControlContentControl>


    </ContentCollection>


</dx:ASPxPopupControl>

<dx:ASPxCallback ID="cbPendingApprovals" ClientInstanceName="cbPendingApprovals" OnCallback="cbPendingApprovals_Callback" runat="server">
    <ClientSideEvents  />
</dx:ASPxCallback>



XML
protected void cbPendingApprovals_Callback(object source, DevExpress.Web.CallbackEventArgs e)
       {
           List<string> fieldNames = new List<string>();
           foreach (GridViewColumn column in gvPendingApprovalList.Columns)
               if (column is GridViewDataColumn)
                   fieldNames.Add(((GridViewDataColumn)column).FieldName);
           List<object> selectedValues = gvPendingApprovalList.GetSelectedFieldValues(fieldNames.ToArray());
       }



but selectedvalues i am getting is 0 items.

Please help
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900