某字段的值为" <aaaa>" 把该字段绑到gd控件, 该 值不能显示出来,怎样才能显示它? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 绑到Datagrid控件不能显示该值 调用了DataGrid的DataBind()方法了没有???DataGrid1.DataBind(); 需要使用转义字符:DataTable dt = new DataTable(); dt.Columns.Add("AAA"); dt.Columns.Add("BBB"); dt.Rows.Add(new object[]{"11111","2222"}); dt.Rows.Add(new object[]{"<33333>","44444"});//相当于“<33333>” this.DataGrid1.DataSource = dt; this.DataGrid1.DataBind(); 还是一句老话:DataGrid实质上就是一个HtmlTable;当绑定 <aaaa>这样的内容的时候就相当于:<table> <tr> <td> <aaaa> </td> </tr></table>这肯定是不合法的Html,在楼主的问题上确实带来了麻烦,但是正是因为这个DataGrid才可以有“按钮列”“模版列”等等的方便的功能 楼上我的dg 控件里可有多个字段,只有topic字段出现这种情况,如用你上方法不是很麻烦。 或者用模版列也可以<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 120px" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:Label id="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "tipic") %>'></asp:Label> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> 看到一个功能效果,求方法! WinFrom中的TreeView获取节点id的问题 服务器报错,请问这是什么错误啊? 刷新页面后,如何保持页面原来的样式 ascx用户控件上的图片在Firefox中显示不出来。 连接SQL Server2005失败:error40;无法打开到SQL Server的连接 在asp.net中怎样包含一个html头文件 dropdownlist 默认值设置? 巨难!,怎样在javascript中访问Multipage控件里的table里的radiobutton控件的属性? 请大神告诉我这里怎么错了 把数据库里边得字符字段清空 如何根据数据表动态生成DateGrid?
DataTable dt = new DataTable();
dt.Columns.Add("AAA");
dt.Columns.Add("BBB");
dt.Rows.Add(new object[]{"11111","2222"});
dt.Rows.Add(new object[]{"<33333>","44444"});//相当于“<33333>”
this.DataGrid1.DataSource = dt;
this.DataGrid1.DataBind();
当绑定 <aaaa>这样的内容的时候就相当于:
<table>
<tr>
<td>
<aaaa>
</td>
</tr>
</table>
这肯定是不合法的Html,在楼主的问题上确实带来了麻烦,但是正是因为这个DataGrid才可以有“按钮列”“模版列”等等的方便的功能
我的dg 控件里可有多个字段,只有topic字段出现这种情况,
如用你上方法不是很麻烦。
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 120px"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label id="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "tipic") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>