1、如何获得SqlDataSource查询的数据条数

解决办法:

在Selected函数中处理:

 

protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        Label1.Text = e.AffectedRows.ToString();
    }
e在sqldatasources的selected事件中加入以上代码e.AffectedRows获取受影响的行数

2、SqlDataSource1.SelectCommand更改数据源的sql查询语句后并不能显示新的sql语句查询的数据

解决办法:改变sql查询语句后需要调用绑定该数据源(SqlDataSource1)的DataBind函数

20120603网站设计问题解决记录_asp.net

 3、为绑定了数据源的DropdownList添加数据项,似乎直接在在空间上添加不行!

  1. if(!IsPostBack) 
  2.             { 
  3.                 DropDownList_news.DataSource = SqlDataSource1; //绑定数据源 
  4.                 DropDownList_news.DataTextField = "Ncaption"//显示内容 
  5.                 DropDownList_news.DataValueField = "Id"//值字段 
  6.                 DropDownList_news.DataBind(); 
  7.                 DropDownList_news.Items.Insert(0, new ListItem("---所有---""-1")); 
  8.                 DropDownList_news.SelectedIndex = 0; 
  9.             }