//建立页面 void BuildView() { //判断并获取数据源 DataTable data = null; string table_name = Request.QueryString["name"]; switch (table_name) { case "type": title = "衣服分类"; TypeList type = new TypeList(); data = type.ReadCount(); break; case "place": title = "存放地点"; PlaceList place = new PlaceList(); data = place.ReadCount(); break; } //建立表格 GridView.DataSource = data; GridView.DataBind(); //添加是否删除的确认弹窗 Button delBtn; for (int i = 0; i < GridView.Rows.Count; i++) { delBtn = (Button)GridView.Rows[i].FindControl("Delete"); delBtn.Attributes.Add("onclick", "javascript:if (confirm('确定要删除吗,将会删除该分类下所有衣服数据')) { return true; } else { return false; }"); } }