Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - ListBox throwing ArgumentOutOfRangeException when adding to DataSource -


i'm trying use bindinglist datasource listbox in c# winforms, whenever try add items bindinglist, argumentoutofrangeexception thrown. following code demonstrates problem (assume form listbox listbox1):

bindinglist<string> datasource = new bindinglist<string>(); listbox1.datasource = datasource; datasource.add("test1"); // exception, here. 

note if datasource has items in it, not exception:

bindinglist<string> datasource = new bindinglist<string>(); datasource.add("test1"); listbox1.datasource = datasource; datasource.add("test2"); // appears work correctly. 

i can work around problem setting datasource property null before adding item, , re-setting datasource afterward, feels hack, , i'd able avoid doing so.

is there (non-hack) way use empty datasource on listbox, such adding items doesn't throw exceptions?

edit: stack trace:

system.windows.forms.dll!system.windows.forms.listbox.selectedindex.set(int value) + 0x1ec bytes
system.windows.forms.dll!system.windows.forms.listcontrol.datamanager_positionchanged(object sender, system.eventargs e) + 0x2e bytes
system.windows.forms.dll!system.windows.forms.currencymanager.onpositionchanged(system.eventargs e) + 0x39 bytes
system.windows.forms.dll!system.windows.forms.currencymanager.changerecordstate(int newposition, bool validating, bool endcurrentedit, bool firepositionchange, bool pulldata) + 0x14f bytes
system.windows.forms.dll!system.windows.forms.currencymanager.list_listchanged(object sender, system.componentmodel.listchangedeventargs e) + 0x2e4 bytes
system.dll!system.componentmodel.bindinglist.onlistchanged(system.componentmodel.listchangedeventargs e) + 0x17 bytes
system.dll!system.componentmodel.bindinglist.firelistchanged(system.componentmodel.listchangedtype type, int index) + 0x35 bytes
system.dll!system.componentmodel.bindinglist.insertitem(int index, system._canon item) + 0x3f bytes
mscorlib.dll!system.collections.objectmodel.collection.add(system.
_canon item) + 0x76 bytes

it turns out had checked in "exceptions" dialog (debug->exceptions). so, exception exists, (silently) handled .net framework. continuing program execution displays expected results.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -