1, put the code in the SqlHelper.
Copy Code code as follows:
#region Intercept string
<summary>
Intercepting strings
</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, Front call:
Copy Code code as follows:
<%# UserInfo.DAL.SqlHelper.leftx (DataBinder.Eval (Container.DataItem, "Title"). ToString (),%>