views:

329

answers:

2

I have the below mentioned method where i am binding DataSource to the combobox control.

    // floorLocnList is coming from a webservice method
    private void lstFloor_BindFloor(FloorLocModel[] floorLocnList)
    {
        this.comboBox1.DataSource = floorLocnList;         
        this.comboBox1.DisplayMember = "Location";
        this.comboBox1.ValueMember = "FloorLoc";
    }

and class defined like this

[Serializable]
public class FloorLocModel
{
    private int floorLoc;
    private string location;

    public int FloorLoc
    {
        get
        {
            return this.floorLoc;
        }
        set
        {
            this.floorLoc = value;
        }
    }

    public string Location
    {
        get
        {
            return this.location;
        }
        set
        {
            this.location = value;
        }
    }
}

Shows Error Value Does not Fall within the Expected Range after reaching the assignment of value to ValueMember

Bug Detail:

   at System.Windows.Forms.ListControl._SetDataBinding(Object newDataSource, BindingMemberInfo newDisplayMember, Boolean fForceRebind)
   at System.Windows.Forms.ListControl.set_ValueMember(String value)
   at IdineSmart.frmLogin.lstFloor_BindFloor(FloorLocModel[] floorLocnList)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.Windows.Forms.Control.TASK.Invoke()
   at System.Windows.Forms.Control._InvokeAll()
   at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.ListView.WnProc(WM wm, Int32 wParam, Int32 lParam)
   at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
   at Microsoft.AGL.Forms.EVL.EnterModalDialog(IntPtr hwnModal)
   at System.Windows.Forms.Form.ShowDialog()
   at IdineSmart.frmMain.frmMain_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at System.Windows.Forms.Application.Run(Form fm)
   at IdineSmart.Program.Main()

It was working fine, but i dono suddenly it started giving me the problem. When i debug the code valuemember is displaying empty string even though i assigned it,might be this is the problem but how it can happen like this. Please help me.

Thanks in advance.

A: 

I'm not sure, but I think I had the same problem.

Try to change the sequence - DataSource at the end.

    this.comboBox1.DisplayMember = "Location";
    this.comboBox1.ValueMember = "FloorLoc";
    this.comboBox1.DataSource = floorLocnList;
Krzysztof Król
It binds the object but displays **MobileTest.TestProxy.FloorLocModel**. Did you do any work around for it..?
Nagaraj
A: 

I Found it at last. Its all because of the error message that shown. But the actual problem was i had few user controls in the project that was targeted the platform Pocket PC 2003 SDK and the main project was targeted Pocket PC 2005 SDK. So i made all my project to target the same SDK then problem solved.

Any way thanks for the response.

Nagaraj