[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

SelectionList DataValueField problem

Brad Wist

7/30/2003 8:35:00 PM

I've got a set of code that is attempting to build a SelectionList. The
values are not sequential. I bind the control to a dataset in which the
values being passed are correct. But the values that are entered into the
selectionlist are simple sequential indexes.

Am I missing something here? Or is this a bug in data binding with the
SelectionList?

Here's the code:


daUnits.Fill(dsMyList);

selUnit.DataSource = dsUnitList;

selUnit.DataTextField = "sName";

selUnit.DataValueField = "Id";

selUnit.DataBind();



And here is an excerpt of the source data

<dbo_spListUnit>
<Id>58</Id>
<sCode>Unit1 </sCode>
<sName>First Unit</sName>
</dbo_spListUnit>
<dbo_spListUnit>
<Id>230</Id>
<sCode>UnitC </sCode>
<sName>Second Unit</sName>
</dbo_spListUnit>
<dbo_spListUnit>
<Id>119</Id>
<sCode>UnitX </sCode>
<sName>Third Unit</sName>
</dbo_spListUnit>

The name appears fine in the list, but the values are consistently 0, 1, 2,
etc... sequential through the list, and do not include the "id" value from
the source data.

Thanks.