Default Values from datasource in Insert Item Template

2 posts, 0 answers
  1. Dave
    Dave avatar
    11 posts
    Member since:
    Jul 2011

    Posted 18 Nov 2011 Link to this post

    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>
  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 22 Nov 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top