protected void BindGrid(int rowcount) { DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add(new System.Data.DataColumn("Document No", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Document Title", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("Revision", typeof(String))); dt.Columns.Add(new System.Data.DataColumn("File", typeof(String))); if (ViewState["CurrentData"] != null) { for (int i = 0; i < rowcount + 1; i++) { dt = (DataTable)ViewState["CurrentData"]; if (dt.Rows.Count > 0) { dr = dt.NewRow(); dr[0] = dt.Rows[0][0].ToString(); } } dr = dt.NewRow(); dr[0] = DropDownList19.Text; dr[1] = DropDownList21.Text; dr[2] = DropDownList20.Text; dt.Rows.Add(dr); } else { dr = dt.NewRow(); dr[0] = DropDownList19.Text; dr[1] = DropDownList21.Text; dr[2] = DropDownList20.Text; dt.Rows.Add(dr); } // If ViewState has a data then use the value as the DataSource if (ViewState["CurrentData"] != null) { GridView1.DataSource = (DataTable)ViewState["CurrentData"]; GridView1.DataBind(); } else { // Bind GridView with the initial data assocaited in the DataTable GridView1.DataSource = dt; GridView1.DataBind(); } // Store the DataTable in ViewState to retain the values ViewState["CurrentData"] = dt; } //////////////////////////add button////////////////////////////////// protected void Button1_Click(object sender, EventArgs e) { // Check if the ViewState has a data assoiciated within it. If if (ViewState["CurrentData"] != null) { DataTable dt = (DataTable)ViewState["CurrentData"]; int count = dt.Rows.Count; BindGrid(count); } else { BindGrid(1); } DropDownList4.Text = string.Empty; DropDownList4.Focus(); { string uploadedFilePath = @"C:\"; string sharePointListPath = "http://path/"; if (FileUpload1.HasFile) try { FileUpload1.SaveAs( uploadedFilePath + FileUpload1.FileName); errorlabaelupload.Text = "File name: " + FileUpload1.PostedFile.FileName + "<br>" + FileUpload1.PostedFile.ContentLength + " bytes<br>" + "Content type: " + FileUpload1.PostedFile.ContentType; UploadFileToSharePoint( uploadedFilePath + FileUpload1.FileName, sharePointListPath + FileUpload1.FileName); } catch (Exception ex) { errorlabaelupload.Text = "ERROR: " + ex.Message.ToString(); } else { errorlabaelupload.Text = "You have not specified a file."; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)