using System; using System.Collections; using System.ComponentModel; using System.Configuration; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CoreLab.MySql;
// Class maillist_config in emotor.builder.maillist namespace emotor.builder.maillist {
public class maillist_config : System.Web.UI.Page {
// SQL Query public string SqlString; // MySql Path public string ConnectionString = ConfigurationSettings.AppSettings["MySqlSource"].ToString();
// Page Load private void Page_Load(object sender, System.EventArgs e) { if (!(IsPostBack)) { // Run Functions dp_Bind(); tb_Bind(); } }
// General MySql Connection public CoreLab.MySql.MySqlConnection OpenMySqlConnection () { CoreLab.MySql.MySqlConnection Conn = new CoreLab.MySql.MySqlConnection(); Conn.ConnectionString = ConnectionString; return Conn; }
// Bind textboxes protected void tb_Bind() { // Set SQL SELECT Query string strID = Request.QueryString["id"]; SqlString = "SELECT * FROM mailconfig WHERE id = '"+ strID +"'";
// Create and fill DataAdapter object CoreLab.MySql.MySqlConnection Conn = OpenMySqlConnection(); Conn.Open(); CoreLab.MySql.MySqlDataAdapter objDataAdapter = new CoreLab.MySql.MySqlDataAdapter(SqlString,Conn); Conn.Close();
// Fill DataSet from DataAdapter DataSet ds = new DataSet(); objDataAdapter.Fill(ds);
// Bind DataSet to DataList dl.DataSource = ds; dl.DataBind(); }
// Bind DropDownList protected void dp_Bind() { // Set SQL SELECT Query SqlString = "SELECT * FROM mailconfig";
// Create and fill DataAdapter object CoreLab.MySql.MySqlConnection Conn = OpenMySqlConnection(); Conn.Open(); CoreLab.MySql.MySqlDataAdapter objDataAdapter = new CoreLab.MySql.MySqlDataAdapter(SqlString,Conn); Conn.Close();
// Fill DataSet from DataAdapter DataSet ds = new DataSet(); objDataAdapter.Fill(ds);
// Bind DataSet to DropDownList dropID.DataTextField = "maillistTitle"; dropID.DataValueField = "id"; dropID.DataSource = ds; dropID.DataBind(); dropID.Items.Insert(0,"-- Vælg en mailing liste --"); //dropID.Attributes.Add("onchange", "jumpMenu('this',this)") ; }
// Event based on DropDownList value protected void dp_Click(object sender, ImageClickEventArgs e) { Response.Redirect("maillist_config.aspx?id=" + dropID.SelectedItem.Value); }
// Updates Textboxes protected void tb_Update(object sender, System.EventArgs e) { // Set command and conn CoreLab.MySql.MySqlConnection Conn = OpenMySqlConnection();
// Set SQL Query string strID = Request.QueryString["id"]; //SqlString = "UPDATE mailconfig SET mailServer = '"+tbMailServer.Text+"', emailAddress = '"+tbEmail.Text+"', messageWelcome = '"+tbWelcomeMsg.Text+"' WHERE id = '"+ strID +"'"; SqlString = "UPDATE mailconfig SET mailServer = '"+((TextBox)FindControl("tbMailServer")).Text+"', emailAddress = '"+((TextBox)FindControl("tbEmail")).Text+"', messageWelcome = '"+((TextBox)FindControl("tbWelcomeMsg")).Text+"' WHERE id = '"+ strID +"'";
Response.Write(SqlString);
// Create Command object MySqlCommand objCommand = new MySqlCommand(SqlString, Conn);
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load);
Jeg har dog samme problem med opdatering af et datagrid (samme fejl) - men det må jeg kigge på igen efter dette her virker.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.