添加绑定控件方法 sshow AllUsers0,代码如下 public void show AllUserso SqlConnection conn new SqlConnection(ConfigurationManager Connection Strings["ConnStr" ConnectionStrin String sqlString ="select* from UserInfo order by UserID desc conn Open; SqlData Adapter adapter new SqlData Adapter(sqlString, conn) Data Table table = new DataTable dapter Fill(table) Details View 1. DataKeyNames= new string{" UserID"};//删除等操作用 Details View 1. DataSource= table. Details View 1. DataBindo conn. close◼ 添加绑定控件方法showAllUsers(),代码如下: ◼ public void showAllUsers() ◼ { ◼ SqlConnection conn = ◼ new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionStrin g); ◼ String sqlString = "select * from UserInfo order by UserID desc"; ◼ conn.Open(); ◼ SqlDataAdapter adapter = new SqlDataAdapter(sqlString, conn); ◼ DataTable table = new DataTable(); ◼ adapter.Fill(table); ◼ DetailsView1.DataKeyNames = new string[] { "UserID" };//删除等操作用 ◼ DetailsView1.DataSource = table; ◼ DetailsView1.DataBind(); ◼ conn.Close(); ◼ }