急,有关Eval("")数据绑定问题
NavigateUrl= 'imagedetail.aspx?ID= <%#DataBinder.Eval(Container.DataItem, "id ")%> '> 问题出在这,连接后,绑定的数据不能解析,地址栏显示NavigateUrl= 'imagedetail.aspx?ID= <%#DataBinder.Eval(Container.DataItem, "id ")%> '> ,而不是NavigateUrl= 'imagedetail.aspx?ID=3
代码如下:
<%@ Page Language= "C# " %>
<%@ Import Namespace= "System.Data "%>
<%@ Import Namespace= "System.Data.OleDb "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
</script>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:DataList ID= "DataList1 " runat= "server " CellSpacing= "8 "
RepeatColumns= "4 " RepeatDirection= "Horizontal " DataSourceID= "AccessDataSource1 " DataKeyField= "id ">
<ItemTemplate>
<asp:Image ID= "Image1 " runat= "server " Height= "152px " ImageUrl= ' <%# Eval( "name ") %> '
Width= "156px " /> <br />
<asp:HyperLink ID= "HyperLink1 " runat= "server " NavigateUrl= 'imagedetail.aspx?ID= <%#DataBinder.Eval(Container.DataItem, "id ")%> '> 详细 </asp:HyperLink>
</ItemTemplate>
</asp:DataList> <asp:AccessDataSource ID= "AccessDataSource1 " runat= "server " DataFile= "~/student.mdb "
SelectCommand= "SELECT [name], [id] FROM [postimage] ORDER BY [time] DESC "> </asp:AccessDataSource>
</div>
</form>
</body>
</html>
[解决办法]
NavigateUrl= ' <%# Eval( "ID ", "~/imagedetail.aspx?ID={0} ") %> '
[解决办法]
地址栏显示NavigateUrl= 'imagedetail.aspx?ID= <%#DataBinder.Eval(Container.DataItem, "id ")%> '>
注意 '在=后
地址栏显示NavigateUrl= "imagedetail.aspx?ID= ' <%#DataBinder.Eval(Container.DataItem, "id ")%> ' ">
[解决办法]
DataNavigateUrlFormatString= 'imagedetail.aspx?ID= <%# DataBinder.Eval(Container.DataItem, "id ")%> '
把NavigateUrl换成上面的看看
[解决办法]
zjh222(zjh) ( ) 信誉:100 Blog 加为好友 2007-05-15 15:08:26 得分: 0
地址栏显示NavigateUrl= 'imagedetail.aspx?ID= <%#DataBinder.Eval(Container.DataItem, "id ")%> '>
注意 '在=后
地址栏显示NavigateUrl= "imagedetail.aspx?ID= ' <%#DataBinder.Eval(Container.DataItem, "id ")%> ' ">
正解
[解决办法]
NavigateUrl= ' <%# "imagedetail.aspx?ID= "+ Eval( "ID ") %> '