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

Accessing a value from RadTextBox in EditFormSetting in RadGrid

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jitendra
Top achievements
Rank 1
Jitendra asked on 29 Nov 2012, 04:35 PM
Hi,

I am trying to get the edited value from RadTextBox which is there in the EditFormSettings in RadGrid.
FileName is Transaction.ascx. Below is the RadGrid. EditFormSettings is highlighted in Bold-itallic.

<telerik:RadGrid ID="grdPaymentHistory" runat="server" AutoGenerateColumns="False"  

CssClass="Grid" Width="800px" Height="180" AllowFilteringByColumn="False" Skin="Windows7" OnNeedDataSource="grdPaymentHistory_NeedsDataSource" AllowSorting="True" DataKeyNames="FinancialTransactionId"  OnItemCommand="grdPaymentHistory_OnItemCommand" OnItemDataBound="grdPaymentHistory_ItemDataBound" OnInsertCommand="grdPaymentHistory_InsertCommand" OnUpdateCommand="grdPaymentHistory_UpdateCommand" OnCustomAggregate="grdPaymentHistory_CustomAggregate" ShowFooter="True"> 

 

<MasterTableView Width="100%" EditMode="EditForms"> 
<RowIndicatorColumn>  <HeaderStyle Width="15px"></HeaderStyle>  </RowIndicatorColumn>

 <ExpandCollapseColumn>

 <HeaderStyle Width="15px"></HeaderStyle>  

</ExpandCollapseColumn>  <Columns>

 <telerik:GridBoundColumn DataField="FinancialTransactionId" UniqueName="FinancialTransactionId"   

Visible="False" /> <telerik:GridBoundColumn HeaderText="Date" DataField="CreatedOn.LocalDateTime" SortExpression="CreatedOn.LocalDateTime"  UniqueName="CreatedOn.DateTime" DataFormatString="{0:MM/dd/yyyy hh:mm tt}" HeaderStyle-Width="110" />  <telerik:GridBoundColumn HeaderText="Transaction" DataField="TransactionType" SortExpression="TransactionType"  UniqueName="TransactionType" />

 

<telerik:GridBoundColumn HeaderText="Payment" DataField="PaymentType" UniqueName="PaymentType"  FilterControlWidth="40px" SortExpression="PaymentType" FooterText="Total:" />

 <telerik:GridBoundColumn HeaderText="Amount" DataField="Amount" UniqueName="Amount"

 SortExpression="Amount" DataFormatString="{0:C}" Aggregate="Custom">

 <ItemStyle HorizontalAlign="Right" />

 <FooterStyle HorizontalAlign="Right" />

 </telerik:GridBoundColumn>

 <telerik:GridEditCommandColumn UniqueName="EditRefundAmount" />

 <telerik:GridBoundColumn HeaderText="GL Acct" DataField="GLAccountId" UniqueName="GLAccountId"

 SortExpression="GLAccountId" />  

<telerik:GridBoundColumn HeaderText="Auth #" DataField="AuthorizationNumber" UniqueName="AuthorizationNumber"

 SortExpression="AuthorizationNumber" /> 

 

<telerik:GridBoundColumn HeaderText="ID" DataField="ProviderTransactionId" SortExpression="ProviderTransactionId" UniqueName="ProviderTransactionId" />

 <telerik:GridBoundColumn HeaderText="User" DataField="CreatedBy" SortExpression="CreatedBy"

 UniqueName="CreatedBy" />  

<telerik:GridBoundColumn HeaderText="Response" DataField="Response" SortExpression="Response"  UniqueName="Response" />  <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Void" HeaderStyle-Width="56px"  DataTextFormatString="Void" HeaderText="Actions" UniqueName="Actions" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" DataTextField="VoidButton" AndCurrentFilterFunction="NoFilter" Visible="True" />

 <telerik:GridTemplateColumn

<HeaderStyle Width="30px" /> <ItemTemplate>

 <asp:Image ID="imgReceipt" runat="server" ImageUrl="~/App_Themes/Default/images/receipt.png"

 ToolTip="View receipt details for printing and emailing" />

 </ItemTemplate>

 <FooterStyle HorizontalAlign="Right"></FooterStyle>  

</telerik:GridTemplateColumn>  </Columns<EditFormSettings EditFormType="Template" InsertCaption="Start Refund Transaction" CaptionFormatString="Edit Follow Up">  <FormTemplate

 

<table>  <tr>  <td >Enter Refund Amount &nbsp;&nbsp;&nbsp;</td

 

<td colspan="3"><asp:RadTextBox runat="server" ID="txtAmount" Text='<%# Eval("Amount") %>'></asp:RadTextBox></td

 

<td>&nbsp;&nbsp;&nbsp;<asp:Button runat="server" ID="btnRefund" Text="Refund" Width="75px" CommandName="Update" /></td>  </tr>  </table>

 </FormTemplate>

 </EditFormSettings

<NoRecordsTemplate> No Transactions Found</NoRecordsTemplate>  </MasterTableView>  <HeaderStyle CssClass="GridHeader" />  <FooterStyle CssClass="GridHeader" /> 

<GroupingSettings CaseSensitive="False" />

<ClientSettings AllowColumnsReorder="false" ReorderColumnsOnClient="True">

<Resizing AllowColumnResize="true" ResizeGridOnColumnResize="false" ClipCellContentOnResize="true" />

 <Scrolling AllowScroll="true" UseStaticHeaders="True" />

 

</ClientSettings

</telerik:RadGrid>
The update command event is as below:
 protected void grdPaymentHistory_UpdateCommand(object sender, GridCommandEventArgs e)
        {  

            //Get the GridEditableItem of the RadGrid
            GridEditableItem editedItem = e.Item as GridEditableItem;

            //Access the textbox from the edit form template and store the values in variables.
            if (editedItem != null)
            {
                var refundAmount = ((RadTextBox)editedItem.FindControl("txtAmount")).Text;
            }
        }



For example, in the txtAmount radtextbox, if the value is showin as 100 and then user is modifying it to 200, in above event, I am getting value as 100 instead of 200.

Please provide a solution in detail.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 30 Nov 2012, 04:24 AM
Hello,

May be your grid will be rebind that's why its replaced new value with old one (Datasource's values) .

Please check that until reach to update event your grid must not rebind (again assigned datasource).

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Jitendra
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or