SelectionList problem

ASP.NET

    Sponsored Links

    Next

  • 1. identify client
    There is a way by code, when a mobile-page is loading, to see the type of client ? if supports img, and so on ?

SelectionList Problem

Postby Sanjay Sood » Sat, 19 Jul 2003 05:27:50 GMT

Hi,

I am having trouble with the SelectionList control.  I am binding the
datasource to a Access OleDbDataReader.  The data shows up properly in the
dropdown menu.  The problem arises when trying to capture the user's
selection by using SelectedIndex.  For some reason it is always
returning -1.  I tried to manually add items (using Items.Add) and
SelectedIndex works fine.  Is there a bug related to using this type of data
binding?

Thanks,

_sanjay




Re: SelectionList Problem

Postby Ran » Wed, 13 Aug 2003 11:00:49 GMT

Hi..did you find out what the problem was??
I have a problem with my databound selectionlist..in my case i use the
item.selected function to find out which item is selected..it works if i
manually add items..but doesnt work when the selectionlist is databound..
Do let me know..

Ran



SelectionList problem

Postby leezard » Tue, 19 Aug 2003 02:43:15 GMT

I have created 4 SelectionList boxes and a Command button. User will make
their selections and hit the Command button, the code below are for the
Command button.

<code>
Sub submit_Click(sender As Object, e As EventArgs)
         Response.redirect("mpaging.aspx?Day=" + Day.SelectedItem.Value +
"&TimeID=" + TimeID.SelectedItem.Value + "&Origin=" +
Origin.SelectedItem.Value + "&DestID=" + DestID.SelectedItem.Value)
     End Sub
</code>

Compiler Error Message: BC30456: 'SelectedItem' is not a member of
'System.Web.UI.MobileControls.SelectionList'.

This error is generated when I hit the Command button, I've copy out this
code from a working ASP.NET webpage. So what is the correct statement to
perform the task above in a mobile webpage?

Thanks in advance.



Re: SelectionList problem

Postby duncan » Fri, 22 Aug 2003 19:59:51 GMT

Hi there,

I believe the method call you need to make is:

Origin.Selection.Value


Similar Threads:

1.Databound SelectionList Problem

Hi,

Can somebody help me out??
This is my problem...I have a Databound Selectionlist on my mobile form.

this is how i fill it

SqlConnection1.Open()
SqlDataAdapter1.Fill(DataSet11, "Authors")
AuthorList.DataBind()
List1.DataBind()

The problem is that i do not get the list of selected values on the other
form.I always get "Select a value" which shd be displayed only when there
are no items selected.The code works if i add items without databinding.ie.,
when i manually do
<mobile:SelectionList id=AuthorList runat="server" SelectType="CheckBox">
<item text = .../>
</mobile:SelectionList >
I am pretty new to ASP.NET and i have no idea what to do....

This is the code i use to display the selected items on another form.

For Each myitem In AuthorList.Items
If (myitem.Selected) Then

If (Text.Length > 0) Then

Text = Text & Separator

End If

Text = Text & myitem.Text & " : " & myitem.Value

End If

Next

If (Text.Length = 0) Then

Text = "Select a Value"

End If

Label1.Text = Text

ActiveForm = Form2

End Sub


2.More Problems with MobileControls.SelectionList

3.selectionList and datareader problem - Please Help!!

I have a selectionList control bounded to a DataReader on a mobile
form like this :
		

cboStreetsSpecific.DataSource = drStreets;
cboStreetsSpecific.DataTextField ="StreetName";
cboStreetsSpecific.DataValueField ="StreetID";  
cboStreetsSpecific.DataBind();  




When I press a Command  button and do Postback , I would like to
retrieve the selected item's text and value. I've tried to do it
inside Command_onClick event like this

private void cmdContinue_Click(object sender, System.EventArgs e)
{
 
   string str= cboStreetsSpecific.Items[cboStreetsSpecific.SelectedIndex].Value);
}

or like this :

private void cmdContinue_Click(object sender, System.EventArgs e)
{
 
   string str= cboStreetsSpecific.Selection.Value;			
}


but it doesn't work. I also tried to retrieve it through Request
object like this :

string str= request.form["cboStreetsSpecific"].ToString();



and it doesn't work either .

When I do the same actions when the selectionList filled without
DataReader all the above attempts to retrieve the selected value DO
WORK !

Please , tell me how can I get the selected value when the
selectionList is bounded to datareader .

Thanks a lot in advance !!

4.SelectionList DataValueField problem

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.


5.Can't retrieve selected text/value of SelectionList after submit - URGENT

I'm unable to retrieve  selected text/value of SelectionList after
submit. Please take a look at the whole page. The problematic line is
inside
 go_Click event . Please help !!! - I'm stuck with it for 3 days
already .

Thank You!!! 


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace mclient1
{
	/// <summary>
	/// Summary description for MobileWebForm1.
	/// </summary>
	public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage
	{
		protected System.Web.UI.MobileControls.Form OriginPoint;
		protected System.Web.UI.MobileControls.Label Label1;
		protected System.Web.UI.MobileControls.Command go;
		protected System.Web.UI.MobileControls.SelectionList cboCities;
		protected System.Web.UI.MobileControls.TextBox street;
		

		private string cityName="";
		private string streetName = "";
		private void Page_Load(object sender, System.EventArgs e)
		{
			
			if (!IsPostBack)
			{
				db Cities = new db((string)Application["connstr"]);
				Cities.getProcName ="sp_select_cities";  
				SqlDataReader drCities = Cities.dr_select_cities()  ;
				string _text ="";
				string _value ="";
				while (drCities.Read())
  
				{
					_text = drCities["CityName"].ToString();
					_value = drCities["CityID"].ToString();
					cboCities.Items.Add(new MobileListItem( "ten"  ,"10"));
					
				}
			}


		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.cboCities.SelectedIndexChanged += new
System.EventHandler(this.SelectedIndexChanged);
			this.go.Click += new System.EventHandler(this.go_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void go_Click(object sender, System.EventArgs e)
		{
			

*** AT THIS POINT  cboCities.Selection IS NULL AND
cboCities.SelectedIndex = - 1****
cityName = cboCities.Selection.Value;
  
		}

		private void SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

6. Databind a SelectionList

7. mobile:SelectionList Item Value Dynamic??

8. MobileControl SelectionList is to small !!



Return to ASP.NET

 

Who is online

Users browsing this forum: No registered users and 57 guest