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

How to get the details table values in ItemCommand ?

1 Answer 224 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bibhudutta
Top achievements
Rank 1
Bibhudutta asked on 20 Jul 2012, 01:33 PM
Hi,

I have a grid in which I have a single details table. I have set the HierarchyLoadMode="Client".
In my details table I have other columns along with two GridTemplate columns, whose Itemtemplate contains RadNumeric textboxes.
For the Grid in CommandItem I ahve a RadToolBar in which I have a "Save" button.

On the "Save" button click on the server side I want to access all the column values along with the two rad numeric text box values for the DeatilsTable, in the code behind.

Please tell me how to do so. This is what I have defined for the grid

<telerik:RadGrid ID="rgBrokerageSettlements" runat="server" AutoGenerateColumns="False"
            BorderStyle="None" Width="100%" EnableLinqExpressions="false" OnNeedDataSource="rgBrokerageSettlements_NeedDataSource"
            OnItemCommand="rgBrokerageSettlements_ItemCommand"
            OnDetailTableDataBind="rgBrokerageSettlements_DetailTableDataBind">
            <MasterTableView DataKeyNames="SettlementHeaderSK" ClientDataKeyNames="SettlementHeaderSK"
                Name="rgBrokerageSettlementsMasterTable" HierarchyLoadMode="Client" AllowSorting="false"
                PagerStyle-Mode="NextPrevAndNumeric" EditMode="InPlace" TableLayout="Fixed" CommandItemDisplay="Top">
                <CommandItemTemplate>
                    <telerik:RadToolBar ID="rtbBrokerageSettlements" runat="server" Width="100%" OnButtonClick="rtbBrokerageSettlements_ButtonClick"
                        OnClientButtonClicking="rgBrokerageSettlements_OnClientButtonClicking">
                        <Items>
                            <telerik:RadToolBarButton Text="Save" ImageUrl="~/Images/save.png" Value="Save" CommandName="Save" />
                        </Items>
                    </telerik:RadToolBar>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="Select" HeaderStyle-Width="25px" ItemStyle-HorizontalAlign="Center"
                        HeaderStyle-HorizontalAlign="Center" />
                    <telerik:GridBoundColumn UniqueName="Document" DataField="Document" HeaderText="Document"
                        DataType="System.String">
                        <HeaderStyle Width="70px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn DataField="DocDate" HeaderText="Doc Date" UniqueName="DocDate"
                        DataType="System.String" SortExpression="DocDate" HeaderStyle-Width="70px">
                        <ItemTemplate>
                            <asp:Label ID="lblDocDate" runat="server" Text='<%# Eval("DocDate") %>' />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>                   
                </Columns>
                <DetailTables>
                    <telerik:GridTableView Name="rgBrokerageSettlementsDetail" AllowFilteringByColumn="False"
                        EnableHeaderContextMenu="false">
                        <Columns>
                            <telerik:GridBoundColumn UniqueName="ItemAndDescription" DataField="ItemAndDescription"
                                HeaderText="Item" DataType="System.String">
                                <HeaderStyle Width="125px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="ItemAmt" DataField="ItemAmt" HeaderText="Item Amount"
                                DataType="System.String">
                                <HeaderStyle Width="125px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="ProgramAmt" DataField="ProgramAmt" HeaderText="Program Amt"
                                DataType="System.String">
                                <HeaderStyle Width="125px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="UnpaidAmt" DataField="UnpaidAmt" HeaderText="Unpaid Amt"
                                DataType="System.String">
                                <HeaderStyle Width="125px" />
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="" HeaderText="Approved Amt" UniqueName="ApprovedAmt"
                                DataType="System.String" SortExpression="" HeaderStyle-Width="70px">
                                <ItemTemplate>
                                    <telerik:RadNumericTextBox ID="radnumtxtbxApprovedAmtDetailsGrid" runat="server"
                                        Width="80px" NumberFormat-NegativePattern="$ -n" NumberFormat-PositivePattern="$ n"
                                        IncrementSettings-InterceptArrowKeys="false">
                                        <ClientEvents OnBlur="radnumtxtbxApprovedAmtDetailsGrid_OnBlur" />
                                    </telerik:RadNumericTextBox>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="" HeaderText="Write off Amt" UniqueName="WriteOffAmt"
                                DataType="System.String" SortExpression="" HeaderStyle-Width="70px">
                                <ItemTemplate>
                                    <telerik:RadNumericTextBox ID="radnumtxtbxWriteOffAmtDetailsGrid" runat="server"
                                        Width="80px" NumberFormat-NegativePattern="$ -n" NumberFormat-PositivePattern="$ n"
                                        IncrementSettings-InterceptArrowKeys="false">
                                        <ClientEvents OnBlur="radnumtxtbxWriteOffAmtDetailsGrid_OnBlur" />
                                    </telerik:RadNumericTextBox>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn UniqueName="" DataField="" HeaderText="Remaining Amt" DataType="System.String">
                                <HeaderStyle Width="125px" />
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
            <ClientSettings AllowExpandCollapse="true">
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                <ClientEvents OnRowSelected="rgBrokerageSettlements_RowSelected" OnRowDeselected="rgBrokerageSettlements_RowDeselected"
                    OnGridCreated="ResizeGrid" OnHierarchyExpanding="rgBrokerageSettlements_OnHierarchyExpanding"
                    OnRowSelecting="rgBrokerageSettlements_RowSelecting" />
            </ClientSettings>
        </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 25 Jul 2012, 07:32 AM
Hello,

 You can have a look at the following help topics which show how you can access controls in cells and detail tables of the grid:
http://www.telerik.com/help/aspnet-ajax/grid-traversing-detail-tables-items-in-grid.html 
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html 
http://www.telerik.com/help/aspnet-ajax/grid-reference-controls-in-edit-form.html 

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Bibhudutta
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or