我的文件(如doc,exl,pdf等)是保存在服務器的硬盤裡,不是保存在數據庫哦..
跟DataGrid选择行操作一样的吧
private void DataGrid2_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.DataGrid2.EditItemIndex = e.Item.ItemIndex;
BuildGrid();
}
private void DataGrid2_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string CategoryID, CategoryName, Description ;
CategoryID = e.Item.Cells[0].Text;
TextBox tb;
tb = (TextBox)e.Item.Cells[1].Controls[0];
CategoryName = tb.Text;
tb = e.Item.Cells[2].Controls[0] as TextBox;
Description = tb.Text;
Dal.CateDal dal = new DbStudy.Dal.CateDal();
dal.Update(CategoryID, CategoryName, Description);
this.DataGrid2.EditItemIndex = -1;
BuildGrid();
}
private void DataGrid2_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.DataGrid2.EditItemIndex = -1;
BuildGrid();
}
private void DataGrid2_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string CategoryID = e.Item.Cells[0].Text;
//access database
BuildGrid();
}
private void DataGrid2_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
LinkButton lb = e.Item.Cells[4].Controls[0] as LinkButton;
lb.Attributes.Add("onclick", "return confirm('是否真的提交!')");
}
}
///以上是編緝,刪除的.下载的我到没做过你在网上找哈