private void setupGroup(string strMethod) { //清除內容 dlGroup.Items.Clear(); //建立Group的DropDownList string strSQL = ""; if (strMethod == "Group") { //By Group strSQL = mySQL.getGroupPaperList(strPaperID); } else if (strMethod == "Author") { //By Author strSQL = mySQL.getAuthorGroupPaperList(strPaperID, hiddenClass.Value, hiddenAuthor.Value); } else if (strMethod == "Class") { //By Class strSQL = mySQL.getClassGroupPaperList(strPaperID, hiddenClass.Value); } else { //By Case strSQL = mySQL.getCaseGroupPaperList(strPaperID, hiddenClass.Value, hiddenCase.Value); } DataSet dsGroup = sqldb.getDataSet(strSQL); if (dsGroup.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsGroup.Tables[0].Rows.Count; i++) { //有資料就把資料加入DropDownList string strText = ""; try { strText = dsGroup.Tables[0].Rows[i]["cGroup"].ToString(); } catch { } string strValue = ""; try { strValue = dsGroup.Tables[0].Rows[i]["cGroup"].ToString(); } catch { } ListItem liGroup = new ListItem(strText, strValue); dlGroup.Items.Add(liGroup); } //加入None ListItem liNone = new ListItem("None", "None"); dlGroup.Items.Add(liNone); } else { //沒有資料的情形 ListItem liGroup = new ListItem("None", "None"); dlGroup.Items.Add(liGroup); } //設定hiddenCase string Value = ""; if (dsGroup.Tables[0].Rows.Count > 0) { Value = dsGroup.Tables[0].Rows[0]["cGroup"].ToString(); } else { Value = "None"; } hiddenGroup.Value = Value; if (Session["Group"] != null) { Session["Group"] = Value; } else { Session.Add("Group", Value); } dsGroup.Dispose(); }