Limit Characters in MultiLine textbox in GridTemplateColumn

2 posts, 0 answers
  1. P
    P avatar
    1 posts
    Member since:
    Sep 2019

    Posted 04 Sep Link to this post

    I am trying to add "Comment" column in the grid which will display "chars remaining" as user types as well as limit max characters allowed in the textbox.

    something like showed here: http://www.aspnet101.com/2009/01/limit-characters-in-multiline-textbox/

    My grid looks like this: 

     

    <telerik:RadGrid RenderMode="Lightweight" AutoGenerateColumns="false"   MasterTableView-DataKeyNames="AttachmentID"    OnNeedDataSource="GridView1_NeedDataSource"  AllowAutomaticUpdates="true"      ID="GridView1"     AllowSorting="True" runat="server" >
            <MasterTableView AllowSorting="true">
                <Columns>               
                    <telerik:GridBoundColumn DataField="AttachmentID" UniqueName="AttachmentID" Visible="false" />
                    <telerik:GridBoundColumn   AllowSorting="true"   DataField="CurriculamYear" UniqueName="CurriculamYear"     HeaderText="Curriculum Year"/> 
                    <telerik:GridHyperLinkColumn  AllowSorting="true" DataNavigateUrlFields="Path" DataNavigateUrlFormatString="{0}"   DataTextField="Name" UniqueName="Name"  HeaderText="Document Type"/> 
                    <telerik:GridBoundColumn  AllowSorting="true"   DataField="FileName" UniqueName="FileName"  HeaderText="File Name"/> 
                    <telerik:GridBoundColumn  AllowSorting="true"   DataField="CreateDate" UniqueName="CreateDate"  HeaderText="Upload Date and Time"/> 
                    <telerik:GridTemplateColumn HeaderText="Comments"  UniqueName="Comments">
                        <ItemTemplate>                       
                            <asp:TextBox ID="txtMessage1"  TextMode="MultiLine" Text='<%# Bind("Comments") %>'  Width="300px"  Rows="3" MaxLength="500"   runat="server"   />                       
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>                 
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

     

     

  2. Eyup
    Admin
    Eyup avatar
    3867 posts

    Posted 09 Sep Link to this post

    Hello,

    You can use telerik:RadTextBox to achieve this automatically:
    <telerik:RadTextBox ... MaxLength="5"   runat="server"   />

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top