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

maxlength not working

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 07 Oct 2013, 12:05 PM
 Hi,

  I have a RadGrid and in which I have enabled filtering option. I want to restrict the length of the text to be entered. But the maxlength option is not working. Can somebody guide me as to why i'm unable to set the maxlength. Or is there some other way I can accomplish this 

thank you
RT

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Oct 2013, 12:19 PM
HI Ryan,

Please try the following code snippet to set the Length of text to be entered.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        GridFilteringItem item = (GridFilteringItem)RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0];
        TextBox txt = (TextBox)item["UniqueName"].Controls[0];
        txt.MaxLength = 5;
    }

Thanks,
Princy
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or