private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName=="edit")
{
Response.Redirect("oa_worklog.aspx?worklogid="+e.Item.Cells[0].Text);
}
else if(e.CommandName=="look")
{
Response.Redirect("oa_worklog_more.aspx?worklogid="+e.Item.Cells[0].Text);
}
}
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName=="del")
{
if (ViewState["filepass"].ToString()=="1")
{
string sqlcmd = "delete from futp_file where id="+e.Item.Cells[0].Text;
Futp_oa.Class.infobase io=new Futp_oa.Class.infobase();
try
{
string str=Server.MapPath("upfiled")+"//"+e.Item.Cells[1].Text;
FileInfo delf;
delf = new FileInfo(str);
delf.Delete();
if (io.Cmdsql(sqlcmd))
{
Response.Write("<script>alert('删除成功');</script>");
ReadGrid();
}
else
{
Response.Write("<script>alert('文件已删除,但数据无法删除');</script>");
}
}
catch
{
Response.Write("<script>alert('数据不正确');</script>");
}
}
else
{
Response.Write("<script>alert('无权删除');</script>");
}
}
}
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
try
{
switch (e.Item.ItemType)
{
case ListItemType.Item:
case ListItemType.EditItem:
case ListItemType.AlternatingItem:
//给按钮增加确认**************************************************************************************
Button myDeleteButton=new Button();
myDeleteButton =(Button)e.Item.Cells[3].Controls[0];
myDeleteButton.Attributes.Add("onclick", "return confirm('您真的要删除吗?');");
break;
}
}
catch(Exception te){Response.Write(te.Message);}
}