public void UpdateAddress_Click(object s, DataListCommandEventArgs e) { CDalAddress oDb = new CDalAddress(); TextBox txtAdrsID; TextBox txtFName; TextBox txtLName; TextBox txtPhone; TextBox txtEMail; TextBox txtWebPage; TextBox txtAge; TextBox txtComments; txtAdrsID = (TextBox)e.Item.FindControl("txtAdrsID"); txtFName = (TextBox)e.Item.FindControl("txtFName"); txtLName = (TextBox)e.Item.FindControl("txtLName"); txtPhone = (TextBox)e.Item.FindControl("txtPhone"); txtEMail = (TextBox)e.Item.FindControl("txtEMail"); txtWebPage = (TextBox)e.Item.FindControl("txtWebPage"); txtAge = (TextBox)e.Item.FindControl("txtAge"); txtComments = (TextBox)e.Item.FindControl("txtComments"); oDb.strConnection = ConfigurationSettings.AppSettings["appStrConnection"]; oDb.Update(Int32.Parse(txtAdrsID.Text) , txtFName.Text , txtLName.Text , txtPhone.Text , txtEMail.Text , txtWebPage.Text , Int16.Parse(txtAge.Text) , txtComments.Text); dlAddress.EditItemIndex = -1; BindData(); }
private void BindData() { CDalAddress oDb = new CDalAddress(); oDb.strConnection = ConfigurationSettings.AppSettings["appStrConnection"]; dlAddress.DataSource = oDb.getAll(); dlAddress.DataBind(); oDb = null; }
public void DeleteAddress_Click(object s, DataListCommandEventArgs e) { CDalAddress oDb = new CDalAddress(); TextBox txtAdrsID; oDb.strConnection = ConfigurationSettings.AppSettings["appStrConnection"]; txtAdrsID = (TextBox)e.Item.FindControl("txtAdrsID"); oDb.Delete(Int32.Parse(txtAdrsID.Text)); // reset edit item index to nothing dlAddress.EditItemIndex = -1; BindData(); }
public void addContact_Click(object s, System.EventArgs e) { // Add a blank record and set the current index to the new row. // display the record in edit style. CDalAddress oDb = new CDalAddress(); Int32 adrsID = 0; oDb.strConnection = ConfigurationSettings.AppSettings["appStrConnection"]; // Add a new record with some defaults. store the New ID for the next step adrsID = oDb.Add("fname", "lname", "() -", "@", "http://", 0, ""); // Use the Id above to fill the DataList in the edit mode dlAddress.DataSource = oDb.getByID(adrsID); dlAddress.EditItemIndex = 0; dlAddress.DataBind(); oDb = null; }