Button bts = e.CommandSource as Button; if(e.CommandName.Equals("FileUpload")) { FileUpload fu = bts.FindControl("fufileupload") as FileUpload; objfile.filename = Path.GetFileName(fu.PostedFile.FileName); objfile.extension = Path.GetExtension(objfile.filename); objfile.contentType = fu.PostedFile.ContentType; file = fu.PostedFile; objfile.FileSize = file.ContentLength; document = new byte[file.ContentLength]; file.InputStream.Read(document, 0, file.ContentLength); DataTable dts = new DataTable(); dts.Columns.Add("Filename", typeof(System.String)); dts.Columns.Add("Extension", typeof(System.String)); dts.Columns.Add("ContentType", typeof(System.String)); dts.Columns.Add("FileSize", typeof(System.Int32)); dts.Columns.Add("document", typeof(byte[])); DataRow drs=dts.NewRow(); //need to set value to MyRow column drs["Filename"] = objfile.filename; // or set it to some other value drs["Extension"] = objfile.extension; drs["ContentType"] = objfile.contentType; drs["FileSize"] = objfile.FileSize; drs["document"] = document; //Listfile.Add(objfile.filename); //Listfile.Add(objfile.extension); //Listfile.Add(objfile.contentType); //Listfile.Add(document); //Listfile.Add(objfile.FileSize); Session["GridRowFile"] = drs; DataTable dt = new DataTable(); DataRow dr; dt = (DataTable)Session["GridRowFile"]; dr = dt.NewRow(); dt.Rows.Add(dr); Session["GridRowFile"] = dt; //object list = (List<object>)Session["GridRowFile"]; //Session.Add("filegrid", list); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)