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

How to obtain value during postback in radtextbox in template column

1 Answer 184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 2
Brian asked on 05 Feb 2015, 09:18 PM
My grid has a template column that contains a radtextbox.  On postback, I want to obtain the value within each radtextbox but it is always returning blank values.  I have the radtextbox in the ItemTemplate, not the EditItemTemplate.  Do I need to do this from an EditItemTemplate and place every row in EditMode?  

Note that the function of the grid is a questionnaire so we want every textbox to be available when the page loads.  We don't want any edit/update links.  

<telerik:RadGrid ID="gvwTextQuestions" runat="server" Width="950px" AutoGenerateColumns="False" DataSourceID="sqlQuestions">
               <MasterTableView EditMode="InPlace" DataKeyNames="QuestionID" CommandItemDisplay="Top" DataSourceID="sqlQuestions">
                   <CommandItemTemplate>
                       <div style="padding-top: 10px; padding-bottom: 10px; padding-left: 10px;">
                           <asp:Label ID="lblHeader" runat="server" Text=""></asp:Label>
                       </div>
                   </CommandItemTemplate>
                   <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False"></CommandItemSettings>
                   <Columns>
                       <telerik:GridBoundColumn DataField="QuestionID" Visible="False" UniqueName="QuestionID" FilterControlAltText="Filter QuestionID column"></telerik:GridBoundColumn>
                       <telerik:GridBoundColumn FilterControlAltText="Filter QuestionNumber column" UniqueName="QuestionNumber" DataField="QuestionNumber">
                           <ItemStyle HorizontalAlign="Center" />
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="Question" UniqueName="Question" FilterControlAltText="Filter Question column"></telerik:GridBoundColumn>
                       <telerik:GridBoundColumn DataField="Required" FilterControlAltText="Filter Required column" UniqueName="Required" Visible="False">
                       </telerik:GridBoundColumn>
                       <telerik:GridTemplateColumn FilterControlAltText="Filter ResponseText column" UniqueName="ResponseText">
                           <ItemTemplate>
                               <telerik:RadTextBox ID="txtResponseText" Runat="server" Columns="90" Rows="6" TextMode="MultiLine" Width="700px">
                               </telerik:RadTextBox>
                           </ItemTemplate>
                           <ItemStyle HorizontalAlign="Left" />
                       </telerik:GridTemplateColumn>
                   </Columns>
               </MasterTableView>
           </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Feb 2015, 11:28 AM
Hello Brian,

You can achieve this requirement by traversing the RadGrid1.Items collection and accessing the textboxes using the FindControl method in order to get their values:
(Accessing Controls in Template Column)
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html


Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Brian
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Share this question
or