代码
<asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Computer;user id=sa; pwd=''"
          SelectCommand="select * from teacherandclass where 教师姓名= ">
      </asp:SqlDataSource>
其中我要把SelectCommand中教师姓名的值在page_load中指名,应该怎么写?

解决方案 »

  1.   

    <asp:SqlDataSource
              id="SqlDataSource1"
              runat="server"
              DataSourceMode="DataReader"
              ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Computer;user id=sa; pwd=''"
              SelectCommand="select * from teacherandclass where 教师姓名=@lookupPassword">
              <SelectParameters>
        <asp:Parameter Name="lookupPassword" Type="String" DefaultValue="" />
      </SelectParameters>
    我想温一下,我应该在那里设置lookupPassword的值?
      

  2.   

    lookupPassword的值我想通过查找数据库指定
      

  3.   

    我想温一下,我应该在那里设置lookupPassword的值?
    >>>>>>>>
    应该是从Url参数、Form表单元素或页面上控件的属性值等传递。
      

  4.   


            <SelectParameters>
                <asp:QueryStringParameter Name="lookupPassword" Type="String"  QueryStringField="name"
                    Type="String" />
            </SelectParameters>