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

Default Values from datasource in Insert Item Template

1 Answer 195 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 18 Nov 2011, 02:51 PM
I have a RadListView that I use to insert data into a SQL table.  Below is a snippet of the Insert Item template 
I have a text box with the ID ScheduleTextBox that is bound to an insert parameter Schedule
 I need to be able to populate the text in this text box from another datasource.
How can I do this?????



Thanks for any help!

Dave


<InsertItemTemplate>
     <tr class="rlvIEdit">
         <td colspan="7">
             <table cellspacing="0" class="rlvEditTable">
                 <tr>
                     <td>
                         <asp:Label ID="Officer_NameLabel2" runat="server"
                             AssociatedControlID="rcbOfficer" Text="Officer_Name"></asp:Label>
                     </td>
                     <td>
                          <telerik:RadComboBox ID="rcbOfficer" runat="server"
                                 DataSourceID="dsOfficer" DataKeyField="Rosterid" DataTextField="officer_name"
                                 DataValueField="officer_name" AllowCustomText="True"  Text='<%# Bind("Officer_Name") %>'>
                         </telerik:RadComboBox>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:Label ID="ScheduleLabel2" runat="server"
                             AssociatedControlID="ScheduleTextBox" Text="Schedule"></asp:Label>
                     </td>
                     <td>
                         <asp:TextBox ID="ScheduleTextBox" runat="server" CssClass="rlvInput"
                             Text='<%# Bind("Schedule") %>' />
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:Label ID="UnitLabel2" runat="server" AssociatedControlID="rcbIUnit"
                             Text="Unit"></asp:Label>
                     </td>
                     <td>
                         <telerik:RadComboBox ID="rcbIUnit" runat="server"
                                 DataSourceID="dsUnit" DataKeyField="Unitid" DataTextField="unit"
                                 DataValueField="unit" AllowCustomText="True"  Text='<%# Bind("unit") %>'>
                         </telerik:RadComboBox>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:Label ID="VehicleLabel2" runat="server"
                             AssociatedControlID="rcbIVehicle" Text="Vehicle"></asp:Label>
                     </td>
                     <td>
                         <telerik:RadComboBox ID="rcbIVehicle" runat="server"
                                 DataSourceID="dsVehicle" DataKeyField="vehicleid" DataTextField="vehiclenumber"
                                 DataValueField="vehiclenumber" AllowCustomText="True"  Text='<%# Bind("vehicle") %>'>
                         </telerik:RadComboBox>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <asp:Label ID="HoursLabel2" runat="server" AssociatedControlID="HoursTextBox"
                             Text="Hours"></asp:Label>
                     </td>
                     <td>
                         <asp:TextBox ID="HoursTextBox" runat="server" CssClass="rlvInput"
                          Text='<%# Bind("Hours") %>'/>
                     </td>
                 </tr>
                 <tr>
                     <td colspan="2">
                         <asp:Button ID="PerformInsertButton" runat="server" CommandName="PerformInsert"
                             CssClass="rlvBAdd" Text=" " ToolTip="Insert" />
                         <asp:Button ID="CancelButton" runat="server" CausesValidation="False"
                             CommandName="Cancel" CssClass="rlvBCancel" Text=" " ToolTip="Cancel" />
                     </td>
                 </tr>
             </table>
         </td>
     </tr>
 </InsertItemTemplate>

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 22 Nov 2011, 04:26 PM
Hi Dave,

You could directly access the textbox inside the Edit or Insert template when the listview enters edit mode, get the value from somewhere else and set it as Text. You can see how controls inside RadListView are accessed in the different templates and modes here:
Accessing Controls in RadListView


Greetings,
Tsvetina
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
ListView
Asked by
Dave
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or