Grid - Using RadInputManager

Next database reset in 0 hours, 16 minutes, 7 seconds
 OrderIDOrderDateFreightShipAddressShipPostalCode 
No records to display.
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB
With RadInputManager you can extend TextBox controls located in control - for instance a repeater or RadGrid.This demo shows how you can add the grid edit form TextBoxes to different RadInputManager settings dynamically.

The following code shows how you could extend all the textboxes nested in a repeater to behave same way:
<telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="Telerik">
	<telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" EmptyMessage="type here" InitializeOnClient="false">
		<TargetControls>
			<telerik:TargetInput ControlID="Repeater1" />
		</TargetControls>
	</telerik:TextBoxSetting>
</telerik:RadInputManager>
<asp:Repeater ID="Repeater1" runat="server">
	<ItemTemplate>
		<asp:TextBox ID="TextBox1" runat="server" />
	</ItemTemplate>
</asp:Repeater>
	

Using this technique you will significantly decrease the input editors loading time since plain MS TextBoxes will be created (instead of the corresponding RadInput controls) and the data entered by the end user will be automatically filtered by RadInputManager, based on the input manager settings. The performance benefit can be quite significant:

  • The same number of input controls will be loaded up to 10 times faster
  • The maximum number of input controls allowed on the page can be 10 times greater

Related Resources

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Input_Examples_RadInputManager_DynamicInputFilterSettings_DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="RadInputManager1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>

    <telerik:RadInputManager RenderMode="Lightweight" ID="RadInputManager1" runat="server">
        <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" InitializeOnClient="false">
        </telerik:TextBoxSetting>
        <telerik:DatePickerSetting BehaviorID="DatePickerBehavior1" InitializeOnClient="false"
            Culture="en-US" DateFormat="MM/dd/yyyy">
        </telerik:DatePickerSetting>
        <telerik:NumericTextBoxSetting BehaviorID="NumericBehavior1" InitializeOnClient="false"
            Type="Number" DecimalDigits="2">
        </telerik:NumericTextBoxSetting>
        <telerik:RegExpTextBoxSetting BehaviorID="RegExpBehavior1" InitializeOnClient="false"
            ErrorMessage="Invalid ShipPostalCode" ValidationExpression="[\w\d-]{4,10}">
            <Validation IsRequired="true"></Validation>
        </telerik:RegExpTextBoxSetting>
    </telerik:RadInputManager>
    <div id="demo" class="demo-container no-bg">
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowMultiRowEdit="true"
            GridLines="None" AllowPaging="True" OnItemCreated="RadGrid1_ItemCreated" AllowAutomaticUpdates="true"
            AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowSorting="true">
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SqlDataSource1"
                CommandItemDisplay="Top">
                <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="FontIconButton">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID"
                        ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" HeaderText="OrderDate"
                        SortExpression="OrderDate" UniqueName="OrderDate" DataFormatString="{0:D}">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Freight" DataType="System.Decimal" HeaderText="Freight"
                        SortExpression="Freight" UniqueName="Freight">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipAddress" HeaderText="ShipAddress" SortExpression="ShipAddress"
                        UniqueName="ShipAddress">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipPostalCode" HeaderText="ShipPostalCode" SortExpression="ShipPostalCode"
                        UniqueName="ShipPostalCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton">
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <EditColumn UniqueName="EditCommandColumn1">
                    </EditColumn>
                    <FormTemplate>
                        <table cellspacing="2" cellpadding="1" width="100%" border="0">
                            <colgroup>
                                <col style="width: 200px;" />
                                <col />
                            </colgroup>
                            <tr>
                                <td colspan="2">
                                    <b>Order:
                                        <%# Eval("OrderID") %>
                                    </b>
                                </td>
                            </tr>
                            <tr>
                                <td>OrderDate:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox1" runat="server" Text='<%# Bind("OrderDate") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>Freight:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox2" runat="server" Text='<%# Bind("Freight") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>ShipAddress:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox3" runat="server" Text='<%# Bind("ShipAddress") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>ShipPostalCode:
                                </td>
                                <td>
                                    <asp:TextBox Width="200px" ID="TextBox4" runat="server" Text='<%# Bind("ShipPostalCode") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Button ID="Button1" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
                                    <asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID" InsertCommand="INSERT INTO [Orders] ([OrderDate], [Freight], [ShipAddress], [ShipPostalCode]) VALUES (@OrderDate, @Freight, @ShipAddress, @ShipPostalCode)"
        SelectCommand="SELECT * FROM [Orders]" UpdateCommand="UPDATE [Orders] SET [OrderDate] = @OrderDate, [Freight] = @Freight, [ShipAddress] = @ShipAddress, [ShipPostalCode] = @ShipPostalCode WHERE [OrderID] = @OrderID">
        <DeleteParameters>
            <asp:Parameter Name="OrderID" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="OrderDate" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="Freight" Type="Decimal"></asp:Parameter>
            <asp:Parameter Name="ShipAddress" Type="String"></asp:Parameter>
            <asp:Parameter Name="ShipPostalCode" Type="String"></asp:Parameter>
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="OrderDate" Type="DateTime"></asp:Parameter>
            <asp:Parameter Name="Freight" Type="Decimal"></asp:Parameter>
            <asp:Parameter Name="ShipAddress" Type="String"></asp:Parameter>
            <asp:Parameter Name="ShipPostalCode" Type="String"></asp:Parameter>
            <asp:Parameter Name="OrderID" Type="Int32"></asp:Parameter>
        </UpdateParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?