ASPx从SQL源在文本框中显示数据

问题描述

|
<asp:sqlDataSource ID=\"textdata\" runat=\"server\"
ConnectionString=\"<%$ ConnectionStrings:TextConnectionString %>\" 
SelectCommand=\"SELECT SUM(pkNot) FROM [Not]\">
    <SelectParameters>
          <asp:ControlParameter ControlID=\"nottotal\" Name=\"pkNot\" PropertyName=\"Text\" Type=\"String\" />
    </SelectParameters>
 </asp:sqlDataSource>
文本框是:
<asp:TextBox runat=\"server\" ID=\"nottotal\"></asp:TextBox>
如何获取该值以显示在文本框中?它不起作用。     

解决方法

那么类似的东西呢:
DataView beh = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

TextBox1.Text = beh[0][0].ToString();
另一种方法可能是:
<asp:TextBox ID=\"TextBox1\" runat=\"server\" Text=\'<%# Bind (\'activitydate\') %>\'></asp:TextBox>
在代码后面。我用c#编写了此代码,因为您没有指出正在使用什么。