<asp:GridView ID="CommentGrid" GridLines="None" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="No." DataField="Num" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Subject Name" DataField="SubjectName">
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="Comment">
<ItemTemplate>
<asp:TextBox ID="CommentBox" runat="server" TextMode="MultiLine" CssClass="commentTbx" MaxLength="2"></asp:TextBox>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
</asp:GridView>
The above Maxlength=”2″ doesnt work!! I even tried other method like databound, and foreach loop to code it but it still fails.
Yes, it is because of
TextMode="MultiLine". You need some javascript to check total chars and impose limit.