protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { id = Convert.ToInt32(e.CommandArgument.ToString()); example = info.GetExampleById(id); Name.Text = example.Name; MainGroup.Text = example.MainGroup; Year.Text = example.Time.Year + ""; Month.Text = example.Time.Month + ""; GetDay(Convert.ToInt32(Year.Text), Convert.ToInt32(Month.Text)); Day.Text = example.Time.Day + ""; Url.Text = example.Url; Type.Text = example.Type; Info.Text = example.Info; if (example.Pic != "") { ShowImg.ImageUrl = example.Pic; Show.Attributes["style"] = "dispaly:block;float:left;margin-left:100px;margin-top:20px"; } else { ShowImg.ImageUrl = "~/FrontState/ExampleShow/ExampleImg/暂无图片.jpg"; Show.Attributes["style"] = "dispaly:block;float:left;margin-left:100px;margin-top:20px"; } }
protected void Cancel_Click(object sender, EventArgs e) { example = info.GetExampleById(id); Name.Text = example.Name; MainGroup.Text = example.MainGroup; Year.Text = example.Time.Year + ""; Month.Text = example.Time.Month + ""; GetDay(Convert.ToInt32(Year.Text), Convert.ToInt32(Month.Text)); Day.Text = example.Time.Day + ""; Url.Text = example.Url; Type.Text = example.Type; Info.Text = example.Info; }
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { id = Convert.ToInt32(e.CommandArgument.ToString()); Model.Example example = new Model.Example(); example = info.GetExampleById(id); if (!DeleteImg(MapPath(example.Pic))) { Response.Write("<script language='javascript'>alert('删除失败!')</script>"); } else { info.Delete(id); Response.Write("<script language='javascript'>alert('删除成功!')</script>"); } DataList1.DataSource = info.GetAll(); DataList1.DataBind(); }
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { int id; Model.Example newexample = new Model.Example(); id = Convert.ToInt32(e.CommandArgument.ToString()); newexample = info.GetExampleById(id); if (newexample.Pic != "") { ShowImg.ImageUrl = newexample.Pic; Show.Attributes["style"] = "dispaly:block;;margin-left:auto;margin-top:20px;margin-right:auto;width:50%"; } else { ShowImg.ImageUrl = "~/FrontState/ExampleShow/ExampleImg/暂无图片.jpg"; Show.Attributes["style"] = "dispaly:block;;margin-left:auto;margin-top:20px;margin-right:auto;width:50%"; } }