Have a radgrid with datas. it works properly.
with a issue.
Issue is:
The MaxLength does not works.
My Code:
<
telerik:GridTemplateColumn UniqueName="Description" DataField="Description" HeaderText="Description">
<ItemTemplate>
<asp:TextBox ID="txtDescription1" Columns="15" MaxLength="255" Rows="2" TextMode="MultiLine" Text='<%#Bind("Description")%>'
runat="server" ReadOnly="true" ></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDescription" Columns="25" MaxLength="255" Rows="5" TextMode="MultiLine" Text='<%#Bind("Description")%>'
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDescription" runat="server" ErrorMessage="*"
ControlToValidate="txtDescription"></asp:RequiredFieldValidator>
</EditItemTemplate>
</telerik:GridTemplateColumn>
I have set the MaxLendth to 255, But it not working
Thank You
-Anto
10 Answers, 1 is accepted
It seems when the TextBox is set to MultiLine mode then the MaxLength propertywill not work. Instead you can use javascript code for validating the enteredcharacters. Check out the following for reference:
Restrict number of characters to be entered in the MultiLine TextBox
Thanks
Shinu.
The link you send me, is for a textbox which is not inside a grid.
It doesn't work in the GridTemplateColumn.
So please can you send me any other option that works in a grid.
Thank You
-Anto
It's not working.
-Anto
To avoid such limitations we recommend you use RadControls - namely the RadTextBox:
| <telerik:RadTextBox |
| ID="RadTextBox1" |
| runat="server" |
| TextMode="MultiLine" |
| MaxLength="5" /> |
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can restrict the length of the Textboxes using server code as shown below:
c#:
| protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem dataItem = (GridDataItem)e.Item; |
| TextBox txtbx = (TextBox)dataItem.FindControl("txtDescription1"); |
| string strtxt = txtbx.Text; |
| if (strtxt.Length > 255) |
| { |
| txtbx.Text = strtxt.Remove(255); |
| } |
| } |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| GridEditableItem editItem = (GridEditableItem)e.Item; |
| TextBox txtbx1 = (TextBox)editItem.FindControl("txtDescription"); |
| string strtxt1 = txtbx1.Text; |
| if (strtxt1.Length > 255) |
| { |
| txtbx1.Text = strtxt1.Remove(255); |
| } |
| } |
| } |
Thanks
Princy.
Thank You for ur reply
I have given radtextbox, it works.
But scrolling appears. Is there any option to avoid it.
-Anto
It is possible to set overflow:hidden to avoid the scrollbars:
| <telerik:RadTextBox |
| ID="RadTextBox2" |
| runat="server" |
| TextMode="MultiLine" |
| MaxLength="255" |
| style="overflow:hidden" /> |
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank You very much.
It works properly.
-Anto
Went for the method given by Daniel.
It works without any problem.
Eventhough thank you for your reply.
-Anto