请问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();     }

解决方案 »

  1.   

    Label1 没有数据源  你还是把Label1
    放到Repeater 或 DataList中把
      

  2.   

    SqlDataSource1.SelectCommand = "select max(feature_id) as feature_id  from [feature]";        Label1.DataBind();
      

  3.   

    还是不行啊Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. 
    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:                             &nbsp;<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