protected void Button1_Click(object sender, EventArgs e) { if (sigma.Count == 0) { Response.Write("<script>alert('你没文章怎么删啊????');</script>"); return; } int wtdelid = sigma[DropDownList1.SelectedIndex].NID; //待删除文章ID int selid = DropDownList1.SelectedIndex; //当前选择id if (ArticleManager.DelArticleById(wtdelid)) { //删除成功 Response.Write("<script>alert('删除成功.');</script>"); sigma.RemoveAt(selid); DropDownList1.Items.Clear(); for (int i = 0; i < sigma.Count; ++i) { ListItem Item = new ListItem(sigma[i].NTitle, i.ToString()); DropDownList1.Items.Add(Item); } if (DropDownList1.Items.Count > 0)//删除以后判断一下..是否DropDownList中还有文章列表呢 { DropDownList1.SelectedIndex = 0; TextBox1.Text = sigma[0].NTitle; TextBox2.Text = sigma[0].NContent; TextBox3.Text = sigma[0].Aname; } else//你写了文章,又删干净了...一切初始化,世界安静了..0.0 { Label1.Text = "你还没有写文章呢,快去写几篇吧."; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; } } else { //删除失败 Response.Write("<script>alert('莫名其妙的删除出错= =????');</script>"); } }