当前位置:编程学习 > C#/ASP.NET >>

数据绑定问题?

<asp:LinkButton ID="lyb" runat="server" Text='<%# Eval("lyb_motif") %>' ToolTip='<%# Bind("lyb_content") %>' PostBackUrl='<%# "~/content.aspx?lybid="& DataBinder.Eval("lyb_id") %>'></asp:LinkButton> 

我想点击后将<%#  Bind("lyb_id") %>参数传递到content.aspx页面lybid=参数

谢谢各位帮我改改那里错了? --------------------编程问答-------------------- <asp:LinkButton ID="lyb" runat="server" Text='<%# Eval("lyb_motif") %>' ToolTip='<%# Bind("lyb_content") %>' PostBackUrl='~/content.aspx?lybid=<%# DataBinder.Eval("lyb_id") %>'></asp:LinkButton> --------------------编程问答-------------------- 楼上的朋友,还是不行啊,出现错误:

http://localhost:3009/aspx/content.aspx?lybid=<%#%20DataBinder.Eval(\"lyb_id\")%20%>


“/aspx”应用程序中的服务器错误。
--------------------------------------------------------------------------------

输入字符串的格式不正确。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.FormatException: 输入字符串的格式不正确。

源错误: 

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 


[FormatException: 输入字符串的格式不正确。]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753219
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
   System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
   System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +257
   System.Web.UI.WebControls.Parameter.get_ParameterValue() +92
   System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +282
   System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +344
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1251
   System.Web.UI.WebControls.AccessDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +179
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +84
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +154
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
   System.Web.UI.WebControls.DetailsView.DataBind() +23
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +91
   System.Web.UI.WebControls.DetailsView.EnsureDataBound() +196
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +101
   System.Web.UI.Control.EnsureChildControls() +134
   System.Web.UI.Control.PreRenderRecursiveInternal() +109
   System.Web.UI.Control.PreRenderRecursiveInternal() +233
   System.Web.UI.Control.PreRenderRecursiveInternal() +233
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435

 


--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.210 --------------------编程问答--------------------
http://localhost:3009/aspx/content.aspx?lybid=<%#%20DataBinder.Eval(\"lyb_id\")%20%>

看上去,你是直接copy上面的代码哦,你都空格都copy代码里去了哦!注意空格哦!

<asp:LinkButton ID="lyb" runat="server" Text='<%# Eval("lyb_motif") %>' ToolTip='<%# Bind("lyb_content") %>' PostBackUrl='~/content.aspx?lybid=<%#DataBinder.Eval("lyb_id") %>'></asp:LinkButton>
--------------------编程问答-------------------- http://localhost:3009/aspx/content.aspx?lybid=<%#DataBinder.Eval(\"lyb_id\")%20%>


“/aspx”应用程序中的服务器错误。
--------------------------------------------------------------------------------

输入字符串的格式不正确。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.FormatException: 输入字符串的格式不正确。

源错误: 

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 


[FormatException: 输入字符串的格式不正确。]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753219
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +43
   System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +293
   System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +257
   System.Web.UI.WebControls.Parameter.get_ParameterValue() +92
   System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +282
   System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +344
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1251
   System.Web.UI.WebControls.AccessDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +179
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +84
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +154
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
   System.Web.UI.WebControls.DetailsView.DataBind() +23
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +91
   System.Web.UI.WebControls.DetailsView.EnsureDataBound() +196
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +101
   System.Web.UI.Control.EnsureChildControls() +134
   System.Web.UI.Control.PreRenderRecursiveInternal() +109
   System.Web.UI.Control.PreRenderRecursiveInternal() +233
   System.Web.UI.Control.PreRenderRecursiveInternal() +233
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4435

 


--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.210 --------------------编程问答-------------------- <asp:LinkButton ID="lyb" runat="server" Text='<%# Eval("lyb_motif") %>' ToolTip='<%# Bind("lyb_content") %>' PostBackUrl='<%# "~/content.aspx?lybid="& DataBinder.Eval("lyb_id") %>'></asp:LinkButton> 

是不是这样的;PostBackUrl='<%# "~/content.aspx?lybid="<%#DataBinder.Eval(Container.DataItem,"lyb_id")%>'></asp:LinkButton> 

--------------------编程问答-------------------- <asp:LinkButton ID="lyb" runat="server" Text='<%# DataBinder.Eval("lyb_motif") %>' ToolTip='<%# DataBinder.Eval("lyb_content") %>' PostBackUrl='~/content.aspx?lybid=<%#DataBinder.Eval("lyb_id") %>'></asp:LinkButton> --------------------编程问答-------------------- 帮顶~~ --------------------编程问答-------------------- 另外~/content.aspx中的~改成相对路径(../的方式)试下.
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,