I have a WebDataGrid and under that i have a TemplateDataField, Header and ItemTemplate. I want to control how many characters are displayed in that field. I tried using MaxLength attribute but it gives an error.
Hi Sagar and welcome to our forums!
What control do you have in the item template? I am going to assume that it's an input.
I tried using this property and it seems to work fine in this case. Can you please take a look at the attached archive?
I have a <asp : HyperLink runat="server" inside the ItemTemplate.
Hello Sagar,
Thank you for the provided information.
I assume that you are using Eval in order to bind some field to the Text attribute of the HyperLink control, and you want to set max length to the value of the corresponding field.
In the sample that Boris provided I've added HyperLink control and with Substring I limit the shown character of the Patient name field. The HyperLink control does not have MaxLength attribute like the input hrml element so you will need to perform some custom solution.
Code snippet:
Another way is to use select statement with substring if you are getting your data from remote database for example.
References:
http://msdn.microsoft.com/en-us/library/ms187748.aspx
http://stackoverflow.com/questions/9628460/select-statement-with-substr-in-where-clause