protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetAllWellHeaders(); } //if (!Page.IsPostBack) //{ //Call Stored procedure //try //{ // Return ID Intentity of Inserted Record // Int32? refint = 1; // WellProfileDataContext dc = new WellProfileDataContext(); // dc.proc_WellXMeterHistoryInsert(ref refint, 14, 37896, "", "", 8, "", 1011, "", "", "", System.DateTime.Now, "", System.DateTime.Now); // dc.SubmitChanges(); //} //catch //{ //} try { string currentuser = Authenication.GetCurrentUserWindowsLogin(); } catch { } bindGridView(); //} /// //MessageLabel.Text = FormView1.CurrentMode.ToString(); //SqlDataSource1 = " SELECT [MeterID],[Manufacturer], [ModelID], [RTUSN], [SecurityCode], [MeterComIDAddress], [PrimaryMeasDevice], [BTUBase], [CreatedBy], [CreateDate], [LastModifiedBy], [LastModifiedDate], [Metername], [MeterDescription], [MeterField], [MeterType], [Filter], [Rank], [Route], [Connect], [ConnectString], [NRI], [CSLink], [Choke], [MeterStatus], [Area], [Formation], [ResponsibleParty1], [SalesPoint], [Reports], [ActiveChoke], [AccountingID], [PC_Outsideoperatedflag], [UnitAddress], [GroupAddress], [MeterAddress], [MeterID] FROM [Meter]"; //SqlDataSource1= }
protected void UpdateButton_Click(Object sender, EventArgs e) { try { //Use the UpdateItem method to programmatically update //the current record in the FormView control. String key = FormView1.DataKey.Value.ToString(); //Calendar cl = new Calendar(); //cl= (Calendar)FormView1.FindControl("createdate"); //cl.SelectedDate = Convert.ToDateTime("12/10/2013"); TextBox txtTextBoxValue = new TextBox(); txtTextBoxValue = (TextBox)FormView1.FindControl("MeternameTextBox"); TextBox txtTextBoxValue1 = new TextBox(); txtTextBoxValue1 = (TextBox)FormView1.FindControl("Meterid"); //TODO //,[CreatedBy] //,[CreateDate] //,[LastModifiedBy] //,[LastModifiedDate] if (FormView1.CurrentMode == FormViewMode.Edit) { TextBox txtTextBoxCreatedBy = new TextBox(); txtTextBoxCreatedBy = (TextBox)FormView1.FindControl("Createdby"); txtTextBoxCreatedBy.Text = Authenication.GetCurrentUserWindowsLogin(); } //Hidden fiels- must be bound to update TextBox txtTextBoxSecurity = new TextBox(); txtTextBoxSecurity = (TextBox)FormView1.FindControl("SecurityCodeTextBox"); TextBox txtTextBoxSecurityEnc = new TextBox(); txtTextBoxSecurityEnc = (TextBox)FormView1.FindControl("Security"); try { txtTextBoxSecurityEnc.Text = Encryption.Encrypt(txtTextBoxSecurity.Text, "NoPass123456789"); } catch { } //End Hidden //TextBox txtTextBoxValue2 = new TextBox(); //txtTextBoxValue2 = (TextBox)FormView1.FindControl("ManufacturerTextBox"); //txtTextBoxValue2.Text = "Eagle"; //Response.Write(txtTextBoxValue.Text); try { FormView1.UpdateItem(true); FormView1.ChangeMode(FormViewMode.Edit); } catch (Exception ex) { MessageLabel.Text = "Error Inserting"; } } catch (HttpException ex) { //MessageLabel.Text = "The FormView control must be in edit mode to update a record."; } }