Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,

                                    I have gridview which is used as an order form(see screenshot). Now, once I edit the quantity or discount and then I want to loop through all rows in the gridview and save the row's ID, qty, discount in my shopping cart(the row's qty >0).

                                    The question is I could not find the way to get like grid.Rows and foreach them.

                                    Help!!!

                                    Cheers,
                                    Kevin

                                shot.gif
                                0

                                Hi Kevin,

                                Please refer to the example linked to this message to learn how to implement this feature.

                                Thanks,
                                Plato

                                0

                                Hi,

                                I used FindRowCellTemplateControl to access my control which is a spinedit and a button click to trigger the grid's callback to perform my logic. But the spinedit always has the same default value. My code is

                                <dxwgv:ASPxGridView Width="100%" ID="gridProducts" ClientInstanceName="clientGridProducts" OnCustomCallback="gridProducts_CustomCallback" DataSourceID="InventoryObjectDataSource"
                                                                                                                     KeyFieldName="ID" runat="server">
                                                                            <Columns>
                                                                                <dxwgv:GridViewDataColumn FieldName="ID" VisibleIndex="0" Visible="false" />
                                                                                <dxwgv:GridViewDataColumn FieldName="ProductName" VisibleIndex="1" />
                                                                                <dxwgv:GridViewDataColumn VisibleIndex="2" HeaderStyle-HorizontalAlign="Right" FieldName="SalePrice" />
                                                                                <dxwgv:GridViewDataColumn Caption="Quantity" VisibleIndex="3">
                                                                                    <DataItemTemplate>
                                                                                        <dxe:ASPxSpinEdit ID="spinMainQuantity" runat="server" Width="100px" MinValue="0"
                                                                                            MaxValue="100" Number="0" NumberType="Integer">
                                                                                        </dxe:ASPxSpinEdit>
                                                                                    </DataItemTemplate>
                                                                                </dxwgv:GridViewDataColumn>
                                                                                <dxwgv:GridViewDataColumn Caption="Discount(%)" VisibleIndex="4">
                                                                                    <DataItemTemplate>
                                                                                        <dxe:ASPxSpinEdit ID="spinMainDiscount" runat="server" Width="100px" MinValue="0"
                                                                                            MaxValue="100" Number="0" NumberType="Float">
                                                                                        </dxe:ASPxSpinEdit>
                                                                                    </DataItemTemplate>
                                                                                </dxwgv:GridViewDataColumn>
                                                                            </Columns>
                                                                        </dxwgv:ASPxGridView>

                                <dxe:ASPxButton ID="btnShowPreview" runat="server" Text="Preview Order Summary">
                                                                                <ClientSideEvents Click="function(s,e){clientGridProducts.PerformCallback('');}" />
                                                                            </dxe:ASPxButton>

                                my codebehind:

                                protected void gridProducts_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
                                    {
                                        GridViewDataColumn colQty = (GridViewDataColumn)gridProducts.Columns[3];
                                        GridViewDataColumn colDiscount = (GridViewDataColumn)gridProducts.Columns[4];
                                        ShoppingCart cart = new ShoppingCart();
                                        for (int i = 0; i < gridProducts.VisibleRowCount; i++)
                                        {
                                            int pID = (int)gridProducts.GetRowValues(i, "ID");
                                            ASPxSpinEdit spinMainQuantity = gridProducts.FindRowCellTemplateControl(i, colQty, "spinMainQuantity") as ASPxSpinEdit;
                                            ASPxSpinEdit spinMainDiscount = gridProducts.FindRowCellTemplateControl(i, colDiscount, "spinMainDiscount") as ASPxSpinEdit;
                                            
                                            if ((int)spinMainQuantity.Number > 0)
                                            {
                                                cart.AddItem(InventoryItem.GeteCommerceInventoryItem(pID), (int)spinMainQuantity.Number, spinMainDiscount.Number);
                                            }
                                        }
                                        cart.Save();
                                    }

                                First time, I perform the callback, value of spinedit will reset to default. Second time is fine but the value is still not correct in codebehind.

                                Did I miss something?

                                Thanks,
                                Kevin

                                0

                                Hi Kevin,

                                Implement your code to fetch editor values in the Page_Load method as I did this in the example provided. In this case, everything should work as expected.

                                Thanks,
                                Plato

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners