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# - populate dropdown list from a list of objects -


in attempt of building 3-tier architecture c# asp.net application, i've started building class database used connecting database, class city has method each column in table cities, , cities class in have getcities method creates list of city objects , use datasource wizard set control use data getcities(). blanks in dropdown list. idea why?

        public list<city> getcities()     {         list<city> cities = new list<city>();         database db = new database();         sqlconnection conn = db.getconnection();         string sql = "select * cities";         sqlcommand cmd = new sqlcommand(sql, conn);         sqldatareader reader = cmd.executereader();          while (reader.read())         {             city c = new city(reader.getint32(0), reader.getstring(1).tostring());             cities.add(c);         }          db.closeconnection();         return cities;     } 

thanks

did set datatextfield, datavaluefield properties, , call databind?


at point try concept working possible, , start adding things in until locate problem. start brand new page, add dropdownlist don't touch data source or change properties, go directly codebehind , add in page_load:

dropdownlist1.datavaluefield = "id"; dropdownlist1.datatextfield = "name"; dropdownlist1.datasource = new[] {     new { id = 1, name = "alice" },     new { id = 2, name = "mike" },     new { id = 3, name = "john" } }; dropdownlist1.databind(); 

does work? me. try change datavaluefield, datatextfield, , datasource work customer list. broken now? know problem in customer list somewhere, not way you're binding data.


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 -