{"id":2057,"date":"2006-09-26T09:08:50","date_gmt":"2006-09-26T16:08:50","guid":{"rendered":"http:\/\/hi-alex.com\/?p=2057"},"modified":"2006-09-26T09:08:50","modified_gmt":"2006-09-26T16:08:50","slug":"limiter-la-taille-de-la-textbox-dun-boundfield","status":"publish","type":"post","link":"http:\/\/www.hi-alex.com\/?p=2057","title":{"rendered":"Limiter la taille de la textbox d&#039;un boundfield"},"content":{"rendered":"<p>[code=c#]<br \/>\npublic class LimitedBoundField : BoundField<br \/>\n{<br \/>\n       private int _characterLimit = 0;<br \/>\n        public int CharacterLimit<br \/>\n        {<br \/>\n            get { return _characterLimit; }<br \/>\n            set { _characterLimit = value; }<br \/>\n        }<br \/>\n         public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)<br \/>\n        {<br \/>\n            base.InitializeCell(cell, cellType, rowState, rowIndex);<br \/>\n            if (rowState == DataControlRowState.Edit &#038;&#038; cellType == DataControlCellType.DataCell)<br \/>\n            {<br \/>\n                TextBox tb = ((TextBox)cell.Controls[0]);<br \/>\n                tb.MaxLength = _characterLimit;<br \/>\n                tb.Text = tb.Text.Substring(0, (tb.Text.Length > _characterLimit) ? _characterLimit : tb.Text.Length);<br \/>\n            }<br \/>\n        }<br \/>\n} [\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[code=c#] public class LimitedBoundField : BoundField { private int _characterLimit = 0; public int CharacterLimit { get { return _characterLimit; } set { _characterLimit = value; } } public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { base.InitializeCell(cell, cellType, rowState, rowIndex); if (rowState == DataControlRowState.Edit &#038;&#038; cellType == DataControlCellType.DataCell) { TextBox tb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2057","post","type-post","status-publish","format-standard","hentry","category-asp-net"],"_links":{"self":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts\/2057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2057"}],"version-history":[{"count":0,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts\/2057\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2057"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}