GridView在配置数据源时,新建连接,测试成功,但下一步时,指定来自表或视图的列为灰色,没法选择,如图
用编程可以实现GridView的填充{
string ConnectionString = "Data Source=JOHN-PC\\SQLEXPRESS;Initial Catalog=asp;Integrated Security=True";
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
// cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from 账户";
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{ GridView1.DataSource = dr;
GridView1.DataBind();
}
}
}
经比较在连接字符串处比SqlDataSource配置数据库时多了\\SQLEXPRESS不知道是不是这儿的问题,该怎么解决,才能使用GridView的配置数据源的功能,请各位赐教!!! --------------------编程问答-------------------- --------------------编程问答--------------------
补充:.NET技术 , ASP.NET