ASP.NET/C# /// DropDown über HashTable ist geschützt?

SG_wXistenZ

Mitglied
Hi,

wie kann ich aus der im folgenden Code erstellten DropDownList wieder Werte auslesen. Obwohl icih den Public gemacht habe, ist der Wert geschützt.!?

thx, eXi




Code:
publicclass WebForm1 : System.Web.UI.Page
 
{
 
protected System.Web.UI.WebControls.DropDownList DropDownList1;
 
protected System.Web.UI.WebControls.TextBox TextBox1;
 
OleDbConnection DBcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Inetpub\\wwwroot\\DMoll\\Nordwind.mdb"); 
 
public Hashtable ht;
 
 
 
 
 
//*** Dieses Beispiel erstellt eine DropDownList aus einer HashTable, wobei der gezeigte Inhalt
 
//*** der DropDownList aus mehreren Feldwerten besteht.
 
 
 
 
 
privatevoid Page_Load(object sender, System.EventArgs e)
{
string strSQL = "SELECT [Bestell-Nr] as BestNum, (Bestelldatum & ' - ' & Lieferdatum & ' - ' & Frachtkosten) AS MeinText FROM Bestellungen";
OleDbCommand cmd = new OleDbCommand(strSQL, this.DBcon);
this.DBcon.Open();
OleDbDataReader dr = cmd.ExecuteReader();
ht = new Hashtable();
int i = 0;
while( dr.Read() )
{
ht.Add(dr["BestNum"].ToString( ), dr["MeinText"] );
i++;
}
this.DBcon.Close();
this.DropDownList1.DataSource = ht;
this.DropDownList1.DataTextField = "value";
this.DataBind();
}
#region Vom Web Form-Designer generierter Code
overrideprotectedvoid OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
privatevoid InitializeComponent()
{ 
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
privatevoid DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e){
this.TextBox1.Text = DropDownList1.SelectedItem.value; 
}
}
 
Zurück