gridview新手问题 我用gridview输出数据库的列表(c#)。但是碰到<>符号的时候,资料会被截断显示。我想替换成<>,请问在gridview里如何替换?我是新手,请直接给代码,越详细越好,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1,可以在绑定数据的时候替换2,可以先格式化dataset数据源,再绑定 <asp:BoundField 加个 HtmlEncode属性设为FALSE试试 void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //throw new Exception("The method or operation is not implemented."); if(e.Row.RowType == DataControlRowType.DataRow) {//假设第一列为需要替换的值的e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace("<","<");e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(">",">"); } } void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //throw new Exception("The method or operation is not implemented."); if(e.Row.RowType == DataControlRowType.DataRow) {//假设第一列为需要替换的值的 e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(" <","<"); e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(">",">"); } } 手动增加一个自定义模板,在里面用Label或者其他绑定到相应的字段,然后在GridView加载的时候通过后台代码格式化。 我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改? 默认情况下,如果显示内容中有HTML标签,比如<BR>,页面会将标签直接显示出来,如果你要让<BR>换行有效,只要将该字段的HTMLEncode属性设置为false就行了如:<asp: BoundField DataField="Title" HeaderTest="Title" HtmlEncode="False">希望对你有用. 我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改? 不好意思,引用错了,#9的方法是不是要先转成template。 我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改? -----新手问题:dataList 中的图片点击后(像是淘宝网一样!)------- 关于DataList绑定的问题,高手看看。。。。 怎么生成类dll文件,然后再怎么调用这个dll文件? 简单问题我倒不会 关于iframe. 命苦,来问问题了哇`` 求助:CreateDirectory创建文件夹失败 如何获取datalist 中的控件??? 2. 假设编写一个ASP.NET,使用动态表格生成技术,将存储Application对象或Cache对象中数据项的名字及其值显示在表格中。 请问如何把DataGrid的某一列变成下拉框 好像是web.config 的问题。求救! js读取xml的问题
{
//throw new Exception("The method or operation is not implemented.");
if(e.Row.RowType == DataControlRowType.DataRow)
{//假设第一列为需要替换的值的
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace("<","<");
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(">",">");
}
}
{
//throw new Exception("The method or operation is not implemented.");
if(e.Row.RowType == DataControlRowType.DataRow)
{//假设第一列为需要替换的值的
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(" <","<");
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(">",">");
}
}
我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改?
<asp: BoundField DataField="Title" HeaderTest="Title" HtmlEncode="False">希望对你有用.
我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改?
我使用这个以后,相应列全部变成空白;要是直接赋值的话就会显示abc(e.Row.Cells[0].Text = "abc");请问怎样修改?