Ok, Ive have read many books and seen a lot of examples of how to bind a drop down list. So I am using VS .net and I use the IDE to create as much code as I can via the GUI. My problem is that the code generated does not match the code people use in examples of binding a dropdownlist. To be honest the examples I understand, the code generated by VS I don't understand but I want to. Any help appreciated.
Here is the code. I am new to this type of programming......be gentle with me!
public class SA_ArptSelNav : System.Web.UI.Page<br />
{<br />
protected System.Web.UI.WebControls.ImageButton ZoomInButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomOutButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomPrevButton1;<br />
protected System.Web.UI.WebControls.ImageButton ZoomExtButton1;<br />
protected System.Web.UI.WebControls.ImageButton PanButton1;<br />
protected System.Web.UI.WebControls.ImageButton PrintButton1;<br />
protected System.Web.UI.WebControls.DropDownList DropDownList1;<br />
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;<br />
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;<br />
protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;<br />
protected System.Data.OleDb.OleDbConnection oleDbConnection1;<br />
protected dbListOfAirports dbListOfAirports1;<br />
protected System.Web.UI.WebControls.ImageButton CopyButton1;<br />
protected DataView dvAirportList;<br />
protected DataTable AirportList; <br />
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
if (!Page.IsPostBack) <br />
{<br />
AirportList = new DataTable(); <br />
dvAirportList = new DataView(AirportList); <br />
<br />
<br />
DropDownList1.DataBind();<br />
}<br />
}<br />
<br />
#region Web Form Designer generated code<br />
override protected void OnInit(EventArgs e)<br />
{<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
<br />
private void InitializeComponent()<br />
{ <br />
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();<br />
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();<br />
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.dbListOfAirports1 = new dbListOfAirports();<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).BeginInit();<br />
this.DropDownList1.DataBinding += new System.EventHandler(this.Page_Load);<br />
this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;<br />
this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;<br />
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;<br />
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {<br />
new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] {<br />
new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"),<br />
new System.Data.Common.DataColumnMapping("AirportID", "AirportID"),<br />
new System.Data.Common.DataColumnMapping("AirportName", "AirportName"),<br />
new System.Data.Common.DataColumnMapping("City", "City"),<br />
new System.Data.Common.DataColumnMapping("Latitude", "Latitude"),<br />
new System.Data.Common.DataColumnMapping("Longitude", "Longitude"),<br />
new System.Data.Common.DataColumnMapping("State", "State")})});<br />
this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;<br />
this.oleDbDeleteCommand1.CommandText = "DELETE FROM tblAirport WHERE (AirportID = ?)";<br />
this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AirportID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AirportID", System.Data.DataRowVersion.Original, null));<br />
this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=0;Data Source=""D:\MGDevelopment\SIMDAC Viewer\DB\simdac_be.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";<br />
this.oleDbInsertCommand1.CommandText = "INSERT INTO tblAirport(AirportCode, AirportName, City, Latitude, Longitude, State" +<br />
") VALUES (?, ?, ?, ?, ?, ?)";<br />
this.oleDbInsertCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportCode", System.Data.OleDb.OleDbType.VarWChar, 4, "AirportCode"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportName", System.Data.OleDb.OleDbType.VarWChar, 50, "AirportName"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("City", System.Data.OleDb.OleDbType.VarWChar, 20, "City"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Latitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Latitude"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Longitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Longitude"));<br />
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("State", System.Data.OleDb.OleDbType.VarWChar, 2, "State"));<br />
this.oleDbSelectCommand1.CommandText = "SELECT AirportCode, AirportID, AirportName, City, Latitude, Longitude, State FROM" +<br />
" tblAirport";<br />
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbUpdateCommand1.CommandText = "UPDATE tblAirport SET AirportCode = ?, AirportName = ?, City = ?, Latitude = ?, L" +<br />
"ongitude = ?, State = ? WHERE (AirportID = ?)";<br />
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportCode", System.Data.OleDb.OleDbType.VarWChar, 4, "AirportCode"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("AirportName", System.Data.OleDb.OleDbType.VarWChar, 50, "AirportName"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("City", System.Data.OleDb.OleDbType.VarWChar, 20, "City"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Latitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Latitude"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Longitude", System.Data.OleDb.OleDbType.VarWChar, 50, "Longitude"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("State", System.Data.OleDb.OleDbType.VarWChar, 2, "State"));<br />
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_AirportID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "AirportID", System.Data.DataRowVersion.Original, null));<br />
this.dbListOfAirports1.DataSetName = "dbListOfAirports";<br />
this.dbListOfAirports1.Locale = new System.Globalization.CultureInfo("en-US");<br />
((System.ComponentModel.ISupportInitialize)(this.dbListOfAirports1)).EndInit();<br />
<br />
}<br />
#endregion<br />
|