protected void Button_Save_Click(object sender, EventArgs e) { SPSite currentSite = SPContext.Current.Site; SPList myList = currentSite.RootWeb.Lists.TryGetList("SharePointDatabase"); try { if (myList != null && FileUpload_Pic.PostedFile != null && FileUpload_Pic.HasFile) { SPListItem listItem = myList.Items.Add(); listItem["Title"] = TextBox_Name.Text; listItem["ProductNumber"] = TextBox_ProdNum.Text; listItem["Color"] = TextBox_Color.Text; listItem["ListPrice"] = TextBox_ListPrice.Text; listItem["MoreInformation"] = TextBox_MoreInfo.Text; string fileName = Path.GetFileName(FileUpload_Pic.PostedFile.FileName); listItem["Image"] = fileName; listItem.Update(); TextBox_Search.Text = string.Empty; TextBox_Name.Text = string.Empty; TextBox_MoreInfo.Text = string.Empty; TextBox_ProdNum.Text = string.Empty; TextBox_Color.Text = string.Empty; TextBox_ListPrice.Text = string.Empty; Label_Exception.Text = "Saved to Database list."; Dispose(); } } catch (Exception x) { Label_Exception.Text = x.Message; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)