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.

delimiter - c# reading in a text file into datatable -


i need read files datatable:

a02   blank031   b02   f357442    c02   f264977    d02   blank037   e02   f272521    f02   e121562    g02   f264972    h02   f332321    a03   e208240    b03   f313854    c03   e229786    d03   e229787    e03   f307584    f03   f357478    

i have weird delimitter , trailing spaces. how read datatable such first column contain 'a02','b02'... , second column contain 'blank031','f357442',etc..

currently doing:

datatable dt = new datatable();                 using (textreader tr = file.opentext(batchesaddresses[index]))                 {                     string line;                     while ((line = tr.readline()) != null)                     {                      string[] items = regex.split(line, ' ');                     if (dt.columns.count == 0)                     {                         // create data columns data table based on number of items                         // on first line of file                         (int = 0; < items.length; i++)                             dt.columns.add(new datacolumn("column" + i, typeof(string)));                     }                         dt.rows.add(items);                      }                 } 

but not working because have trailing spaces , multiple spaces between columns

if use:

static readonly char[] space = { ' ' }; ... string[] items = line.split(space, stringsplitoptions.removeemptyentries); 

you should 2 values expect, although more selective might desirable, if right-hand-side might contain space in middle.


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 -