listbox selecteditem error - asp.net

There have an error
"Object Reference not set to an
instance of an object"
when using objusername.intuserid=listbox1.selecteditem.value.

Check if listbox1.SelectedItem is null, or listbox1.SelectedIndex = -1 before accessing the property. This basically means nothing is selected.

Your ListBox1 can also return Text using SelectedValue property iff value has set to that before. But above is more effective way to get text.
Now, the value is something that is not visible to user but it is used mostly to store in database. We don't insert Text of ListBox1, however we can insert it also, but we used to insert value of selected item. To get value we can use
ListBox1.SelectedValue

Related

property-set is not setting value

I am trying to set 'emailid' value from table records into a property and then pass this property as input to 'To' in sendemailnotification method. When i run tracer, parameter is not being set, it is empty, so i get message saying atleast one emailid is required(to or cc or bcc).
I can see once the when rule in property-set is being validated, property values is not set, it is directly going to child item which is call sendemailnotification. 'To' is empty:
got this. Solved this by adding ".Emailid" also in the Obj-Browse.

Editable combo is not properly binding to model property

I am using org.eclipse.swt.widgets.Combo which is not read only, meaning a user can insert any string or may select from the dropdown box.
But when I bind it to my model class property I get Null Pointer Exception whenever I am entering any text which is not present in the combo.
databindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(ComboReporterId),
BeansObservables.observeValue(Model, TextReporter_M));
Please help on this issue.
For a Combo where text can be entered you will need to observe the text:
IObservableValue targetOV = WidgetProperties.text().observe(combo);
You will have to bind this to a value that is a String (or use a Converter).

Adobe LiveCycle Dropdown box databinding to Text Field

To Whom It May Concern:
I have a Dropdown list that populate a Text Field based on below code:
TextField.rawValue = Dropdownlist.rawValue
The user is Allowed Custom text Entry.
What I need is if the user adds his own text the textfield.rawValue should be empty
So far I have the follow script:
If (Dropdownlist.selectedIndex == Dropdownlist.selectedindex)
TextField.rawValue = Dropdownlist.rawValue
else
textfield.rawValue = "Empty"
endif
if I run this I get on the textField the value of "Empty" although I have selected a value that has a specific value assigned.
Your assistance is appreciated
That is in FormCalc and I work in javascript but the issue is in the logic, not in the syntax.
In your current setup the if statement condition will always evaluate to true - Dropdownlist.selectedIndex will always equal itself.
However, if the user has entered a custom value then the selectedIndex for that dropdown will be -1, so you can test for that.
Use this condition instead in your If statement:
(Dropdownlist.selectedIndex <> -1)

DropDownList can't bind to DbNull

I have a DropDownList trying to bind to DbNull and it's not happy about it. I've seen advice about creating a ListItem with value=" " but this isn't working.
Any help would be much appreciated.
if you want to add default value to dropdwon list you can do it as below
mydropdown.DataSource = getdata();
mydropdown.DataBind();
mydropdown.Items.Insert(0,new ListItem("N/A","N/A"));
Edit
if you know some values of the datasouce is null than y dont you filter out those value at database level and than bind soruce with the drop down.
or
make use of Isnull() in query and assing default value to null values.
It shouldn't work to bound DBNull while the other items are e.g. of type int.
With a white space or empty string I got problems too. So best way would be to change your DBNull entry with a constant value, that would not appear in your database and have the same data type like the other entries, for example -1.

Webcombo return error when trying to populate based on another WebCombo

This has gotten me completely frustrated
I have a few webcombo boxes that are hierachial:
Continent
Country
When the form loads everything works fine, when I change the continent the first time, the country repopulates correctly. However if I change the continent a second time I receive an error:
Specified argument was out of the range of valid values.Parameter name: The DataValueField of ValueField was not found in the Columns collection.
Can anyone tell me why?
P.S. This is all I have in the Page_Load event
if (!IsPostBack)
{
this.Load_AreaList();
this.Load_AreasOfInterest();
this.Load_Degrees();
this.Load_GenderList();
this.Load_ParticipationDateModifiers();
this.Load_ProgramCategories(nEventID);
this.Load_YesNoList();
this.Load_ParticipantInformation(nParticipantID);
}
Also this happens in another part of the form with another Country webcombo which is supposed to populate a state combo box.
In many cases, columns in database tables return null when no value is stored in that column. However, a null value can present challenges when you are working with ASP.NET code or with data-bound Web controls. For example, an exception is thrown if you try to bind the SelectedValue of a DropDownList control to null. If this is not the case change AppendDataBoundItems property. The AppendDataBoundItems property allows you to add items to the ListControl object before data binding occurs. After data binding, the items collection contains both the items from the data source and the previously added items.
Let me know if it works...
s

Resources