|
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
private List<DocumentFile> _documents
{
get
{
if (ViewState["Documents"] == null)
ViewState["Documents"] = new List<DocumentFile>();
return (List<DocumentFile>)ViewState["Documents"];
}
set
{
ViewState["Documents"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
DataBind();
}
public override void DataBind()
{
base.DataBind();
grdDocuments.DataSource = _documents;
grdDocuments.DataBind();
}
protected void lnkAddDocument_Click(object sender, EventArgs e)
{
if (IsValid)
{
TempUpload tempUpload = new TempUpload(fileDocument);
String documentPath = tempUpload.SaveFile();
_documents.Add(new DocumentFile(Guid.NewGuid().ToString(), txtDocumentTitle.Text, documentPath));
DataBind();
txtDocumentTitle.Text = String.Empty;
}
}
protected void butAddFolder_Click(object sender, EventArgs e)
{
if (IsValid)
{
// 1. Insert Folder in table and get ID
// 2. Using Folder ID insert All Uploaded Documents
// and move files from Temp folder to permanent storage
foreach (DocumentFile document in this._documents)
{
}
}
}
protected void grdDocuments_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "DeleteDocument":
foreach (DocumentFile document in _documents)
{
if (document.ID.Equals(e.CommandArgument))
{
_documents.Remove(document);
break;
}
}
DataBind();
break;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Alexander is freelance web developer with 4 years experience. He has skills in ASP.NET/MS SQL Server, PHP/MySQL, Ruby On Rails, XHTML, CSS. You can contact with me by
seigo.ua@gmail.com. Also check my homepage at
www.klalex.com.