Accessing a row of data
-
I have finally solved my dropdownlist databinding issue....Next prolem. I now have a selected value. That value correpsopnds to a row of data. How do I access this data? Here is my code. Thanks in advance
private void Page_Load(object sender, System.EventArgs e) { // Create a DropDownList control. DropDownList DropList = new DropDownList(); // Set the properties for the DropDownList control. DropList.ID = "AirportList"; DropList.AutoPostBack = true; // Manually register the event-handling method for the // SelectedIndexChanged event. DropList.SelectedIndexChanged += new EventHandler(this.Selection_Change); oleDbDataAdapter1.Fill(dsn_AirportList1,"tblAirport"); Session["DSN_AirportList"] = dsn_AirportList1; DropList.DataSource = dsn_AirportList1; // DropList.DataTextField = "AirportName"; // Bind the data to the control. DropList.DataBind(); // Set the default selected item when the page is first loaded. if(!IsPostBack) { DropList.SelectedIndex = 0; } // Add the DropDownList control to the Controls collection of // the PlaceHolder control. PlaceHolder1.Controls.Add(DropList); } #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); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter(); this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand(); this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection(); this.dsn_AirportList1 = new DSN_AirportList(); ((System.ComponentModel.ISupportInitialize)(this.dsn_AirportList1)).BeginInit(); // // oleDbDataAdapter1 // this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1; this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"), new System.Data.Common.DataC
-
I have finally solved my dropdownlist databinding issue....Next prolem. I now have a selected value. That value correpsopnds to a row of data. How do I access this data? Here is my code. Thanks in advance
private void Page_Load(object sender, System.EventArgs e) { // Create a DropDownList control. DropDownList DropList = new DropDownList(); // Set the properties for the DropDownList control. DropList.ID = "AirportList"; DropList.AutoPostBack = true; // Manually register the event-handling method for the // SelectedIndexChanged event. DropList.SelectedIndexChanged += new EventHandler(this.Selection_Change); oleDbDataAdapter1.Fill(dsn_AirportList1,"tblAirport"); Session["DSN_AirportList"] = dsn_AirportList1; DropList.DataSource = dsn_AirportList1; // DropList.DataTextField = "AirportName"; // Bind the data to the control. DropList.DataBind(); // Set the default selected item when the page is first loaded. if(!IsPostBack) { DropList.SelectedIndex = 0; } // Add the DropDownList control to the Controls collection of // the PlaceHolder control. PlaceHolder1.Controls.Add(DropList); } #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); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter(); this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand(); this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection(); this.dsn_AirportList1 = new DSN_AirportList(); ((System.ComponentModel.ISupportInitialize)(this.dsn_AirportList1)).BeginInit(); // // oleDbDataAdapter1 // this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1; this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"), new System.Data.Common.DataC