using System;
using System.Collections;
using System.ComponentModel;
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 eInfoDesigns.dbProvider.MySqlClient;

namespace typesproject
{
	/// <summary>
	/// Summary description for helprequest.
	/// </summary>
	public class helprequest : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button btnContinue;
		protected System.Web.UI.WebControls.HyperLink lnkMainMenu;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label lblTitle;
		protected System.Web.UI.WebControls.DropDownList lstHeroes;
		protected System.Web.UI.WebControls.Label lblHelp;
		protected System.Web.UI.WebControls.DataGrid grdHeroes;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!(this.IsPostBack)) 
			{
				string sql = "select * from superheroes";
				string cnstr = "server=localhost;uid=;pwd=;database=csharpvqs;";

				MySqlConnection cn = new MySqlConnection(cnstr);
				cn.Open();
				MySqlCommand cmd = new MySqlCommand(sql, cn);
				DataSet ds = new DataSet();
				MySqlDataAdapter da = new MySqlDataAdapter();
				da.SelectCommand = cmd;
				da.Fill(ds);
				
				lstHeroes.DataSource = ds;
				lstHeroes.DataTextField = "Name";
				lstHeroes.DataBind();
				grdHeroes.DataSource = ds;
				grdHeroes.DataBind();
			}		
		}

		#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.btnContinue.Click += new System.EventHandler(this.btnContinue_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnContinue_Click(object sender, System.EventArgs e)
		{
			Session["hero"] = lstHeroes.SelectedItem.Text;
			Response.Redirect("schedule.aspx");
		}
	}
}
