62,046
社区成员
发帖
与我相关
我的任务
分享
BLL.About bll = new BLL.About();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetDateView();
}
}
protected void myGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
myGridView.EditIndex = -1;
}
protected void myGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "com")
{
string id = e.CommandArgument.ToString();
BLL.About Bll = new BLL.About();
DataSet ds = Bll.GetList("id=" + id);
if (ds != null && ds.Tables[0].Rows.Count != 0)
{
dropList.SelectedValue = ds.Tables[0].Rows[0]["type"].ToString();
FCKeditor1.Value = ds.Tables[0].Rows[0]["details"].ToString();
txtbox1.Text = ds.Tables[0].Rows[0]["id"].ToString();
}
}
}
protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void myGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string id = myGridView.DataKeys[e.RowIndex].Value.ToString();
BLL.About Bll = new BLL.About();
bool a= Bll.Delete();
if (a)
{
Response.Write("<script>alert('删除成功');</script>");
}
else
{
Response.Write("<script>alert('删除失败');</script>");
}
GetDateView();
}
protected void myGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
myGridView.EditIndex = e.NewEditIndex;
}
protected void myGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
protected void u23_Click(object sender, EventArgs e)
{
if (txtbox1.Text == "" || txtbox1.Text == null)
{
Model.About model = new Model.About();
model.details = this.FCKeditor1.Value;
model.type = this.dropList.SelectedValue.ToString();
bool a = bll.Add(model);
if (a)
{
Response.Write("<script>alert('添加成功');</script>");
GetDateView();
}
else
{
Response.Write("<script>alert('添加失败');</script>");
GetDateView();
}
}
else
{
Model.About model = new Model.About();
model.id = Convert.ToInt32(this.txtbox1.Text);
model.details = this.FCKeditor1.Value;
model.type = this.dropList.SelectedValue.ToString();
if (bll.Update(model))
{
Response.Write("<script>alert('修改成功');</script>");
GetDateView();
}
else
{
Response.Write("<script>alert('修改失败');</script>");
GetDateView();
}
}
}
protected void u24_Click(object sender, EventArgs e)
{
this.FCKeditor1.Value = "";
this.txtbox1.Text = "";
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
// myGridView.DataKeys[e.RowIndex].Value.ToString();
}
protected void GetDateView()
{
DataSet ds = new DataSet();
ds = bll.GetList(5, this.AspNetPager1.CurrentPageIndex, "", "id", "id,type,details");
AspNetPager1.RecordCount = int.Parse(ds.Tables[1].Rows[0][0].ToString());
this.myGridView.DataSource = ds;
this.myGridView.DataBind();
this.txtTitle.Text = "";
this.FCKeditor1.Value = "";
this.txtbox1.Text = "";
}