3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 12 Feb 2009, 04:44 AM
Hi,
I hope you are trying to set the MaxLength of the TextBox when the Grid is in edit mode. If so you can either try setting in the aspx or in the code behind as shown below.
ASPX:
or
CS:
Thanks
Shinu
I hope you are trying to set the MaxLength of the TextBox when the Grid is in edit mode. If so you can either try setting in the aspx or in the code behind as shown below.
ASPX:
<telerik:GridBoundColumn DataField="ProductName" MaxLength="5" HeaderText="ProductName" UniqueName="ProductName"> |
</telerik:GridBoundColumn> |
or
CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
// in insert mode |
if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) |
{ |
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; |
TextBox txtbx = (TextBox)insertItem["ProductName"].Controls[0]; |
txtbx.MaxLength = 5; |
} |
//in edit mode |
if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) |
{ |
GridEditFormItem editItem = (GridEditFormItem)e.Item; |
TextBox txtbx = (TextBox)editItem["ProductName"].Controls[0]; |
txtbx.MaxLength = 5; |
} |
} |
Thanks
Shinu
0
surya
Top achievements
Rank 1
answered on 20 Jan 2016, 04:55 PM
Hello Shinu,
I am facing the same issue.I tried both the ways ,neither of it worked in my case.I am using Version 2013.My req is to allow user to enter only 10 characters.i am using radgrid batch editng mode cell.could you please help with that..
Thanks
0
Hello Surya,
Please note that Batch editing mode is different than other modes. You can find a detailed explanation in the following section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode
You can find related information for implementing Batch editing with templates in this article:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/working-with-templates
Hope this helps.
Regards,
Eyup
Telerik
Please note that Batch editing mode is different than other modes. You can find a detailed explanation in the following section:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode
You can find related information for implementing Batch editing with templates in this article:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing/working-with-templates
Hope this helps.
Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items