2
用下面的函数把字符串转义一下再存入数据库public static string MyHtmlEncode(string strContent)
{
strContent=strContent.Replace("&","&");
strContent=strContent.Replace("'","''");
strContent=strContent.Replace("<","<");
strContent=strContent.Replace(">",">");
strContent=strContent.Replace("chr(60)","<");
strContent=strContent.Replace("chr(37)",">");
strContent=strContent.Replace("\"",""");
strContent=strContent.Replace(";",";");
strContent=strContent.Replace("\r\n","<br>");
strContent=strContent.Replace(" "," ");
return strContent;
}
用下面的函数把字符串转义一下再存入数据库public static string MyHtmlEncode(string strContent)
{
strContent=strContent.Replace("&","&");
strContent=strContent.Replace("'","''");
strContent=strContent.Replace("<","<");
strContent=strContent.Replace(">",">");
strContent=strContent.Replace("chr(60)","<");
strContent=strContent.Replace("chr(37)",">");
strContent=strContent.Replace("\"",""");
strContent=strContent.Replace(";",";");
strContent=strContent.Replace("\r\n","<br>");
strContent=strContent.Replace(" "," ");
return strContent;
}
<img src='<%#Show(DataBinder.Eval(Container.DataItem,"DataTime"))'..... >public show(object obj)
{
判断时间,并返回IMG URL;
//do some thing
}2.使用Replace进行替换
str.Replace("\n","<br>")
作者:孟宪会
http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1
if(e.Item.ItemIndex!=-1)
{
if(DataGrid2.DataKeys[e.Item.ItemIndex].Equals("1"))
{
foreach(Control imag in e.Item.Cells[1].Controls)
{
if(imag.ID=="Image1")
{
imag.Visible=true;
}
}
}
else
{
foreach(Control imag in e.Item.Cells[1].Controls)
{
if(imag.ID=="Image1")
{
imag.Visible=false;
}
}
}
其中:DataKeys是你判断时间是否符合条件的值
<img src="aaa/b.gif" border=0>
谁会这个问题,用qq交流