请问vs2005怎么样绑定数据到label,我想在label1上显示,数据库feature表中feature_id的最大值但显示错误,说不能这样绑定,
代码如下: <asp:Label ID="Label1" runat="server" Text='<%# Eval("feature_id") %>'></asp:Label></td>
cs
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand = "select max(feature_id) from [feature]"; Label1.DataBind(); }
代码如下: <asp:Label ID="Label1" runat="server" Text='<%# Eval("feature_id") %>'></asp:Label></td>
cs
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand = "select max(feature_id) from [feature]"; Label1.DataBind(); }
解决方案 »
- 请问怎么用SqlParameter写入16进制数据?顺便问下一个ASP.NET项目怎么生成多个DLL?
- 大侠们,推荐一本ajax的书籍,我是学ASP.NET的,应该买什么书??谢谢
- ASP.NET中如何获取数据库中图像的长宽
- 超级难
- 快速得到数据
- 100分请教 如何把XBM格式转换为GIF或者BMP格式?
- JS+XML客户端分页(ajax异步)
- 请问任意点击DATAGRID触发什么事件
- 为什么使用sp_executesql执行存储过程返回的数据不可以传给DataSet?
- 日期的格式问题 有人帮忙看看吗
- 如何备份远程数据库(sql server)到本地机器上?
- DataGrid1_ItemDataBound和DataGrid1_ItemCommand,这两个事件有什么区别?
放到Repeater 或 DataList中把
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.Source Error:
Line 26: </td>
Line 27: <td style="width: 314px; height: 13px; text-align: left">
Line 28: <asp:Label ID="Label1" runat="server" Text='<%# Eval("feature_id") %>'></asp:Label></td>
Line 29: </tr>
Line 30: <tr>
Source File: e:\website\SndFBOM\security\newfeature.aspx Line: 28