This is a migrated thread and some comments may be shown as answers.

Radgrid GridBoundColumn Multiline MaxLength

3 Answers 618 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 11 Feb 2009, 03:36 PM
Hello
I have a radgrid. When I add a record, in the edit mode, I would like to set a maxlength to my gridBoundColumn which is multiline. I saw that I can't do that, does it have a workaround for this?

Thanks!

3 Answers, 1 is accepted

Sort by
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:

<
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
Eyup
Telerik team
answered on 25 Jan 2016, 12:00 PM
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
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
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
surya
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or