我在页面绑定了一些信息
显示部分内容跟标题
本地看到的信息是正确的
可是到了网上只有标题
没有信息了
这是为什么呢
//数据绑定
protected void BindNews()
{
string ziduan = "top 3 fabu_id,fabu_biaoti,fabu_neirong";
string biao = "new_fabu";
string where = "fabu_dalei = 1 and fabu_jincheng = 0";
string order = "fabu_time desc";
SqlDataReader dr = DBHelper.GetReader(ziduan, biao, where, order);
xezx_DataList.DataSource = dr;
xezx_DataList.DataKeyField = "fabu_id";
xezx_DataList.DataBind();
}
//新闻内容截取字符
protected string NeiRongjiequ(string oldStr)
{
string newStr = "";
if (oldStr.Length > 25)
{
//替换文本中的换行
newStr = DBHelper.NoHTML(oldStr).Substring(0, 23) + "...";
}
else
{
newStr = oldStr;
}
return newStr;
}
//新闻标题截取字符
protected string Biaotijiequ(string oldStr)
{
string newStr = "";
if (oldStr.Length > 10)
{
//替换文本中的换行
newStr = DBHelper.NoHTML(oldStr).Substring(0, 7) + "...";
}
else
{
newStr = oldStr;
}
return newStr;
}
///去除代码中的HTML标记
/// <summary>
/// 去除HTML标记
/// </summary>
/// <param name="NoHTML">包括HTML的源码 </param>
/// <returns>已经去除后的文字</returns>
public static string NoHTML(string Htmlstring)
{
//删除脚本
Htmlstring = Regex.Replace(Htmlstring,@"<script[^>]*?>.*?</script>","",RegexOptions.IgnoreCase);
//删除HTML
Htmlstring = Regex.Replace(Htmlstring,@"<(.[^>]*)>","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"([\r\n])[\s]+","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"-->","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"<!--.*","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(quot|#34);","\"",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(amp|#38);","&",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(lt|#60);","<",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(gt|#62);",">",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(nbsp|#160);"," ",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(iexcl|#161);","\xa1",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(cent|#162);","\xa2",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(pound|#163);","\xa3",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(copy|#169);","\xa9",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);","",RegexOptions.IgnoreCase);
Htmlstring.Replace("<","");
Htmlstring.Replace(">","");
Htmlstring.Replace("\r\n","");
Htmlstring=HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
return Htmlstring;
}
这是我的绑定代码有什么问题吗
这样有什么问题吗