Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dropdown List 101
Message
De
20/05/2005 10:52:27
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
19/05/2005 16:37:50
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 1.1
OS:
Windows 2000 SP4
Database:
MS SQL Server
Divers
Thread ID:
01015644
Message ID:
01016203
Vues:
13
>>>I have the standard scenario:
>>>
>>>1. A lookup table, call it "Values". This table has 2 columns: Value_PKey and Value_Desc.
>>>
>>>2. A data table, with 3 columns storing foreign Value_PKey values (they will be different).
>>>
>>>I'd like to configure dropdown lists to show the current values of the 3 data columns, plus all the other available choices so each may be changed to a different value.
>>>
>>>I've gotten to the point where I can either DataBind() to a DataTable to populate the dropdown items, or spin through the DataTable and populate manually with Items.Add(). However, I don't see how to attach a separate DataSet table (or whatever) to this dropdown list.
>>>
>>>I'm probably missing something fairly fundamental. Can anyone point me to an online tutorial or code sample(s) that shows how to do this?
>>
>>Al,
>>
>>Binding in ASP.NET is one-way. You can use DataBind to populate dropdownlists and grids, but updates to the datasource have to be coded. In the event that performs the update (e.g. mybutton_Click, myddl_SelectedIndexChanged), use the .SelectedItem.Key property of the ddl to update the DataTable with the foreign key values.
>>
>>Also, ASP.NET ddl's are not the same as comboboxes. The user will be limited to one of the choices in the lookup table.
>
>Thanks for the "one-way" concept - that's a key thing I was missing.
>
>I'm not seeing a .SelectedItem.Key property on my ddls (I'm using VS 2003 / 1.1). If this is present can you show some code that specs these values? If it (or something like it) could store ints that would be handy, AFAICS the various ddl fields can hold only string values.

Oops. The property is SelectedItem.Value (and SelectedItem.Text is the part that is displayed).

Unfortunately, there are no ASP.NET web controls that use Integers because it all gets rendered to HTML - which uses strings for everything.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform