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