Versions des environnements
>>>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement