[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

Reg. MobileListItemCollection to a SelectionList control

Prabakaran

1/7/2002 1:30:00 PM

Here,

1. I create a list of MobileListItem Object and assign
different info. for TEXT and VALUE properties.

2. And Add this list of MobileListItem object to MobileListItemColletion
object.

3. Assign the MobileListItemCollection object to SelectionList Control

below is the source code I used
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MobileListItemCollection v_oListItems = new MobileListItemCollection();
for (int iRow=0;iRow<iRows;iRow++)
{
MobileListItem v_oListItem = new MobileListItem();
if (oDS.Tables["Result"].Columns.Count > 1)
v_oListItem.Text = oDS.Tables["Result"].Rows[iRow][1].ToString();
else
v_oListItem.Text = oDS.Tables["Result"].Rows[iRow][0].ToString();

v_oListItem.Value = oDS.Tables["Result"].Rows[iRow][0].ToString();
v_oListItems.Add(v_oListItem);
}

SelectionList1.DataSource = v_oListItems;
SelectionList1.DataBind();

Output for the above code is...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<select name="SelectionList1"><option value="0">B98765
<option value="1">B98767
<option value="2">B78295
<option value="3">B98768
<option value="4">B97777
</select>

My Question is,
~~~~~~~~~~~~~~~
SelectionList control have two types of informations,
1. Display info. [TEXT property]
2. "VALUE" property which one is not displayed and for internal uses.

Here, B98765, B98767, B78295 are all assigned by me through TEXT property
but, the values in VALUE property 0,1,2,3..... are not assiged by me.
Actually I assign a different values in that property

Why the values assiged by me are not comming, instead of 0,1,2,3.....?

Also I tried it with the following source code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
......
......
foreach MobileListItem m in v_oListItems
{
SelectionList1.Items.Add(m);
}
========================
Help me out.
========================





1 Answer

CodeJockey

1/7/2002 8:19:00 PM

0

The runtime assigns numeric values to lesson the transport load. I'll bet if
you check what the user selected (SelectionList1.Selection) you'll find one
of your values.


"Prabakaran" <News_Praba@hotmail.com> wrote in message
news:uiig9c3lBHA.2524@tkmsftngp02...
> Here,
>
> 1. I create a list of MobileListItem Object and assign
> different info. for TEXT and VALUE properties.
>
> 2. And Add this list of MobileListItem object to MobileListItemColletion
> object.
>
> 3. Assign the MobileListItemCollection object to SelectionList Control
>
> below is the source code I used
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> MobileListItemCollection v_oListItems = new MobileListItemCollection();
> for (int iRow=0;iRow<iRows;iRow++)
> {
> MobileListItem v_oListItem = new MobileListItem();
> if (oDS.Tables["Result"].Columns.Count > 1)
> v_oListItem.Text = oDS.Tables["Result"].Rows[iRow][1].ToString();
> else
> v_oListItem.Text = oDS.Tables["Result"].Rows[iRow][0].ToString();
>
> v_oListItem.Value = oDS.Tables["Result"].Rows[iRow][0].ToString();
> v_oListItems.Add(v_oListItem);
> }
>
> SelectionList1.DataSource = v_oListItems;
> SelectionList1.DataBind();
>
> Output for the above code is...
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> <select name="SelectionList1"><option value="0">B98765
> <option value="1">B98767
> <option value="2">B78295
> <option value="3">B98768
> <option value="4">B97777
> </select>
>
> My Question is,
> ~~~~~~~~~~~~~~~
> SelectionList control have two types of informations,
> 1. Display info. [TEXT property]
> 2. "VALUE" property which one is not displayed and for internal uses.
>
> Here, B98765, B98767, B78295 are all assigned by me through TEXT property
> but, the values in VALUE property 0,1,2,3..... are not assiged by me.
> Actually I assign a different values in that property
>
> Why the values assiged by me are not comming, instead of 0,1,2,3.....?
>
> Also I tried it with the following source code
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ......
> ......
> ......
> foreach MobileListItem m in v_oListItems
> {
> SelectionList1.Items.Add(m);
> }
> ========================
> Help me out.
> ========================
>
>
>
>
>