Hello,
Use following BreakLong String function and call this function as following way
<asp:TemplateField HeaderText="Address1" HeaderStyle-HorizontalAlign="Left">
<EditItemTemplate>
<asp:TextBox ID="txtAddress1" runat="server" Text='<%# Eval("DrpValue") %>' Width="90px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblAddress1" runat="server" Text='<%# BreakLongString(Eval("DrpValue").ToString(),10) %>' Width="90px"></asp:Label>
</ItemTemplate>
<ItemStyle Width="90px" />
<HeaderStyle Width="90px" />
</asp:TemplateField>
public string BreakLongString(string SubjectString, int CharsToBreakAfter)
{
string Pattern = "\\S{" + CharsToBreakAfter + ",}";
int Counter = 0;
bool IsMatching = Regex.IsMatch(SubjectString, Pattern);
while (IsMatching)
{
Counter++;
string MatchedString = Regex.Match(SubjectString, Pattern).Value;
SubjectString = SubjectString.Replace(MatchedString.Substring(0, (CharsToBreakAfter - 1)), MatchedString.Substring(0, (CharsToBreakAfter - 1)) + " ");
// Prevent endless loops
if (Counter > 20) break;
// Check if we still have long strings
IsMatching = Regex.IsMatch(SubjectString, Pattern);
}
return SubjectString;
}
Hope this helpful!
Thanks