1.CodePut it in sqlhelper.
Copy code The Code is as follows: # region intercepts a string
/// <Summary>
/// Capture a string
/// </Summary>
/// <Param name = "str_value"> </param>
/// <Param name = "str_len"> </param>
/// <Returns> </returns>
Public static string leftx (string str_value, int str_len)
{
Int p_num = 0;
Int I;
String new_str_value = "";
If (str_value = "")
{
New_str_value = "";
}
Else
{
Int len_num = str_value.length;
For (I = 0; I <= len_num-1; I ++)
{
If (I> len_num) break;
Char c = convert. tochar (str_value.substring (I, 1 ));
If (INT) C> 255) | (INT) C <0 ))
P_num = p_num + 2;
Else
P_num = p_num + 1;
If (p_num> = str_len)
{
New_str_value = str_value.substring (0, I + 1 );
Break;
}
Else
{
New_str_value = str_value;
}
}
}
Return new_str_value;
}
# Endregion
2. Foreground call: Copy codeThe Code is as follows: <% # userinfo. Dal. sqlhelper. leftx (databinder. eval (container. dataitem, "title"). tostring (), 20) %>