<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>c#</title>
        <link>http://geekswithblogs.net/gaijin42/category/3032.aspx</link>
        <description>c#</description>
        <language>en-US</language>
        <copyright>Jason Coyne</copyright>
        <managingEditor>geekswithblogs-gaijin42@sneakemail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Question for you about virtual functions</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2008/04/10/virtual_functions_final_subclass_inherit.aspx</link>
            <description>&lt;font size="2"&gt;
&lt;p&gt;Is there a way in a subclass to mark a particular function as "final". That is, I have base class A. A declares a virtual function. B inherits, and overrides the function. C inherits B. I want to prevent C from overrideing the function again, but still have it work virtually as far as A and B are concerned.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Any help?&lt;/p&gt;
&lt;/font&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121162"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121162" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/121162.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2008/04/10/virtual_functions_final_subclass_inherit.aspx</guid>
            <pubDate>Thu, 10 Apr 2008 22:09:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/121162.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2008/04/10/virtual_functions_final_subclass_inherit.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/121162.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/121162.aspx</trackback:ping>
        </item>
        <item>
            <title>Using a datatable to update rows and not insert when the row did not originate in the datatable with acceptchanges() and setmodified()</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2007/09/05/update_dataset_with_new_rows_acceptchanges_setmodified_orm_business_objects.aspx</link>
            <description>&lt;p&gt;One of my recent applications had an issue which is probably very common.  &lt;/p&gt;
&lt;p&gt;I was fetching data out of a database and putting it into a datatable, and then converting the datatable to a collection of business objects. Later, the collection of business objects needed to be commited back to the database, however the original dataset is no longer around. Therefore, when I create rows in my dataset to update back to the database, the data adapter actually attempted to insert new rows, when the rows in question already exist.&lt;/p&gt;
&lt;p&gt;The most obvious answer is to select the data back out before the update, change the data in the dataset, and then update. But that causes an extra roundtrip to the database, when I dont care about the data in the database any longer.  Also, when updating multiple rows, the business objects would have to be matched up against the dataset, which could be problematic.&lt;/p&gt;
&lt;p&gt;My next solution was to use an update query as the insertcommand of the dataset,  and call the update statement. This worked fine, but was clunky. you could not do a real insert and an update in the same operation. &lt;/p&gt;
&lt;p&gt;I finally came across this solution, which is quite elegant and very easy to implement. using the row.AcceptChanges() and row.SetModified() functions you can make the data adapter correctly call the update statement.  row.AcceptChanges() marks the row as unchanged, then SetModified() sets it as updated, even though it started as added.  You cannot call SetModified without calling AcceptChanges, as the setmodified function only works on rows that are set as unmodified.&lt;/p&gt;
&lt;p&gt;Hopefully the entire ORM problem is solved in the future by things like LINQ, but until then, this is a nice workaround.&lt;/p&gt;
&lt;p&gt;semi-psudocode example&lt;br /&gt;
&lt;br /&gt;
//fetch data and populate business objects&lt;br /&gt;
MyStrongDataSet ds = FetchDataFromDatabase();&lt;br /&gt;
List&amp;lt;bizobjects&amp;gt;  biz = ConvertDataSetToObjects(ds);&lt;br /&gt;
&lt;br /&gt;
//remove dataset from memory to simulate real world disconnection from data&lt;br /&gt;
ds = null;&lt;br /&gt;
&lt;br /&gt;
//modify biz objects&lt;br /&gt;
DoSomeWork(biz);&lt;br /&gt;
&lt;br /&gt;
//populate empty dataset with business objects data&lt;br /&gt;
ds = new MyStrongDataSet();&lt;br /&gt;
foreach (bizobjects currentBiz in biz)&lt;br /&gt;
{&lt;br /&gt;
DataRow row = ds.NewRow();&lt;br /&gt;
row.Someval = currentBiz.Someval;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;//Here is the magic&lt;br /&gt;
ds.rows.add(row);&lt;br /&gt;
row.AcceptChanges();&lt;br /&gt;
row.SetModified();&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
dataAdpater.update(ds);&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;update&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If you are getting a "Concurrency violation" using my example, here is the solution&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By default, the dataadapter creates an update statement that checks&lt;br /&gt;
all of the column's original values. Since the datarow used in this&lt;br /&gt;
solution does not know the true original values of the row, only your&lt;br /&gt;
updated values, that code fails.&lt;br /&gt;
&lt;br /&gt;
The solution is to modify the update statement used by the dataadapter&lt;br /&gt;
to only use the primary key for the where clause.  Its pretty easy to&lt;br /&gt;
autogenerate such a query by looping through your datatable schema and&lt;br /&gt;
creating "set clauses" for each column, and then a single where&lt;br /&gt;
condition, or you could hand code a statement up and assign it to the&lt;br /&gt;
updatecommand.  In my code I use an automatically generated update&lt;br /&gt;
statement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=115168"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=115168" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/115168.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2007/09/05/update_dataset_with_new_rows_acceptchanges_setmodified_orm_business_objects.aspx</guid>
            <pubDate>Thu, 06 Sep 2007 03:17:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/115168.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2007/09/05/update_dataset_with_new_rows_acceptchanges_setmodified_orm_business_objects.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/115168.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/115168.aspx</trackback:ping>
        </item>
        <item>
            <title>I just got my MCP.</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2006/06/14/tech_ed_boston_mcp_mcad_certification_testing.aspx</link>
            <description>&lt;P&gt;&amp;nbsp;Got my MCP on test 70-135 : Web Applications with C#&lt;/P&gt;
&lt;P&gt;The test was pretty easy, but several of the questions were worded ambiguously in my opinion. Tech Ed has a 50% discount on certifications, with a free second try if you screw up the first time.&amp;nbsp; I have a few more days, maybe I will try and kick out another two tests and get my MCAD or something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=81902"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=81902" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/81902.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2006/06/14/tech_ed_boston_mcp_mcad_certification_testing.aspx</guid>
            <pubDate>Wed, 14 Jun 2006 21:36:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/81902.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2006/06/14/tech_ed_boston_mcp_mcad_certification_testing.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/81902.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/81902.aspx</trackback:ping>
        </item>
        <item>
            <title>Tech Ed : Next Generation Data Access in .Net Applications with ADO.NET vNext</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2006/06/13/tech_ed_ado_linq_entity_data_model_IExtendedDataRecord_pablo_castro.aspx</link>
            <description>&lt;P&gt;Yesterday I went to Microsoft's Pablo Castro's presentation about the next version of ADO.Net. This presentation covered LINQ (Language Integrated Query) and some new features like the Entity Data Model.&lt;/P&gt;
&lt;P&gt;Many of you are probably familliar with LINQ, but every time I see it, I want to start using it right away. Unfortunately my company is a slow adopter, and we aren't even on 2005 yet :(&lt;/P&gt;
&lt;P&gt;The Entity Data Model is seperate from LINQ, but works hand in hand with it to provide some very imperssive features. &lt;/P&gt;
&lt;P&gt;Using some GUI designers (or presumably by manually editing some XML files), you can map from your logical table schema, to a real business schema. &lt;/P&gt;
&lt;P&gt;Pablo's example used the AdventureWorks database, and remapped the Contacts, Person, and SalesPerson entities into one SalesPerson business entity. The tables are split up in the logical layer for normalization reasons, but from a business perspective, there is no reason to interact with it at that level.&lt;/P&gt;
&lt;P&gt;You create the mapping between your tables and the entities, and then you can query the entity as if it were the table. Esentially making a view. However, the views are updateable, which is a nice touch. Also, The features allow you to abstract away data conventions. For example, in the same AdventureWorks database, There are Sales. However, there is a convention in the data that if the Tax is 0, then that was a StoreSale.&amp;nbsp; When yuo select out the collection of Sales, you get some sales, and some StoreSales, automatically cast for you, based on the conventions you define in the mapping. &lt;/P&gt;
&lt;P&gt;All of this is queried through Entity SQL, a new version of the SQL language that supports the additional features that the EDM platform provides.&lt;/P&gt;
&lt;P&gt;A new &amp;#8220;MAP&amp;#8221; provider has been created that you run your connections and commands against, and this provider translates from Entity SQL to the native SQL your database requires. A nice side effect of this is true database agnostic access.&amp;nbsp; Even if you just did a one to one table to entity mapping, you would still get the database abstarction, which is a great feature. All of this new functionality is exposed through a new IExtendedDataRecord interface, which is esentially a datareader, with the additional schema information that EDM provides.&lt;/P&gt;
&lt;P&gt;The other big win for this is DataSet queries. You can treat your DataSet just like another data source for the mapping. The big benefit for this is that the same tools you use for true DB access you use for DataSet access, no new semantics or incompatible tools!&lt;/P&gt;
&lt;P&gt;Of course, all of this works with LINQ as well, so you can get LINQ collection iteration etc, on your business entities, rather than your raw tables.&lt;/P&gt;
&lt;P&gt;Also, your business entities are exposed as objects, which can be extended to add functionality. So you get all the benefits of an object layer on your data, for very little effort.&lt;/P&gt;
&lt;P&gt;This is very exciting.&amp;nbsp; Pablo says the bits for Entity Data Model should be available later this year, and I am really looking forward to it.&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=81711"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=81711" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/81711.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2006/06/13/tech_ed_ado_linq_entity_data_model_IExtendedDataRecord_pablo_castro.aspx</guid>
            <pubDate>Tue, 13 Jun 2006 17:43:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/81711.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2006/06/13/tech_ed_ado_linq_entity_data_model_IExtendedDataRecord_pablo_castro.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/81711.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/81711.aspx</trackback:ping>
        </item>
        <item>
            <title>Elegant communication from child to parent in .net via events</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2006/02/20/using_custom_events_for_elegant_communication_from_child_to_parent_using_events_.aspx</link>
            <description>&lt;P&gt;Communicating elegantly from a child to a parent in programming is something that it took me a long time to figure out.  I tried all sorts of kludgy solutions, like passing in a reference to the parent as a parameter to the constructor/method of the child, etc.  This invariably leads down a bad path.  Of course, the correct solution is events.  The event model is something every developer uses all the time, because of the seamless way Visual Studio (or any other modern IDE) automatically generate event handlers for you when you do things like double click on buttons in the designer. However, creating custom events, and passing data via the event is something that eludes many. &lt;/P&gt;
&lt;P&gt;I recently saw a &lt;A href="http://www.eggheadcafe.com/forums/forumsearchbranch.asp?THREADID=60972&amp;INTID=2"&gt;post on egghead cafe&lt;/A&gt; where a user was asking this question, and the reply that he got was leading him down the same dead-end I described above.  I posted out an event example on egghead, but thought I would post it here as well to get a bit more visability to the solution.  The code below is nothing unique, its been written a million times before, but it took me a while to figure it out the first time, so hopefully someone gets some use out of it.&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;!--StartFragment --&gt; Here is an example of some an event I raise in one of my ASP.net forms. Very simmilar code will work with no problems in winforms. &lt;BR&gt;Put this first snippet anywhere inside your namespace (but not inside any other class) &lt;BR&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;PRE class=PreSourceCode&gt; &lt;BR&gt;//Create a new event handler delegate, so that you can pass information back to the form. You could use the standard EventHandler, but then you can't pass any info back. &lt;BR&gt; public delegate void SearchUpdateEventHandler(object sender, SearchUpdateEventArgs e); &lt;BR&gt; &lt;BR&gt;//Here is a class that you use to hold the info that gets passed back. It has to decend from EventArgs. &lt;BR&gt;    public class SearchUpdateEventArgs : EventArgs &lt;BR&gt;    { &lt;BR&gt;        public SearchQuery searchQuery; &lt;BR&gt; &lt;BR&gt;        public SearchUpdateEventArgs(SearchQuery searchQuery) &lt;BR&gt;        { &lt;BR&gt;            this.searchQuery = searchQuery; &lt;BR&gt;        } &lt;BR&gt;    } &lt;BR&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR&gt;Then, in your control, have the following code &lt;BR&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;PRE class=PreSourceCode&gt; &lt;BR&gt;//Create the event so your form can listen for it &lt;BR&gt;public event SearchUpdateEventHandler UpdateSearchCriteria; &lt;BR&gt; &lt;BR&gt;//In your button/link, raise the event back to the form. &lt;BR&gt; private void lnk_Click(object sender, EventArgs e) &lt;BR&gt;        { &lt;BR&gt;            searchQuery.SearchText += " " + ((LinkButton) sender).Text; &lt;BR&gt;            Results = searchQuery.Search(); &lt;BR&gt; &lt;BR&gt;            //This line makes it so you only raise the event if someone is listening. &lt;BR&gt;            if (UpdateSearchCriteria!=null) &lt;BR&gt;                //Raise the event, and pass in the data (searchQuery in this case) that you want to send to the form. &lt;BR&gt; &lt;BR&gt;                UpdateSearchCriteria(this, new SearchUpdateEventArgs(searchQuery)); &lt;BR&gt;        } &lt;BR&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR&gt;&lt;BR&gt;Finally, in your main form, you have code that listens for the event. This is just like any other event you have on your form for buttons etc. &lt;BR&gt;&lt;BR&gt;These last two snippets can be generated automatically using the events (lightning bolt) button on the properties window at design time. &lt;BR&gt;&lt;BR&gt;Put this line of code somewhere in your onLoad (or the winforms equivilent) &lt;BR&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;PRE class=PreSourceCode&gt; &lt;BR&gt;SearchResultDisplay3.UpdateSearchCriteria+=new SearchUpdateEventHandler(SearchResultDisplay3_UpdateSearchCriteria); &lt;BR&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;BR&gt;&lt;BR&gt;and then your actual event (just like normal buttons) &lt;BR&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;PRE class=PreSourceCode&gt; &lt;BR&gt;  private void SearchResultDisplay3_UpdateSearchCriteria(object sender, SearchUpdateEventArgs e) &lt;BR&gt;        { &lt;BR&gt;//Or set your textbox or whatever &lt;BR&gt;            SearchCriteria1.UpdateForm(e.searchQuery); &lt;BR&gt;        } &lt;/PRE&gt;&lt;/DIV&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70171"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=70171" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/70171.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2006/02/20/using_custom_events_for_elegant_communication_from_child_to_parent_using_events_.aspx</guid>
            <pubDate>Tue, 21 Feb 2006 00:34:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/70171.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2006/02/20/using_custom_events_for_elegant_communication_from_child_to_parent_using_events_.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/70171.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/70171.aspx</trackback:ping>
        </item>
        <item>
            <title>Word Wrap function for c# (.net)</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2006/01/23/c-sharp-word-wrap-function-dotnet.aspx</link>
            <description>&lt;P&gt;Most of the technical posts I make on this blog, are issues that I struggle with for a day or two, and was unable to find a good solution for on the internet. Once I find the solution, I try to post it here, to try and make things easier on everyone else out there.  I made a similar post to usenet microsoft.public.dotnet.faqs group last April, about doing word wrap in .net.  This weekend, someone sent some feedback from my blog asking if that post was mine, and thanking me for the information. I really appreciated the comment, since it is hard to tell if people out there need and use the information I post. &lt;/P&gt;
&lt;P&gt;In any case, I decided to repost the word wrap function to my blog, in hopes that more people can get some use out of it.&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Wrap&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;maxLength&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"\n"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"\r"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"."&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;". "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"&gt;"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"&gt; "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"\t"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;","&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;", "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;";"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"; "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"&lt;br&gt;"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Words&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Split&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;' '&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLineLength&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ArrayList&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Lines&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ArrayList&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;text&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt; / &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;maxLength&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InTag&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;foreach&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Words&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;//ignore html &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt; &gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Substring&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1&lt;/FONT&gt;&lt;FONT size=2&gt;) == &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"&lt;"&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InTag&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InTag&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;//handle filenames inside html tags &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;EndsWith&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"."&lt;/FONT&gt;&lt;FONT size=2&gt;)) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; += &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; += &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt; + &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IndexOf&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"&gt;"&lt;/FONT&gt;&lt;FONT size=2&gt;) &gt; -&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;InTag&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;false&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLineLength&lt;/FONT&gt;&lt;FONT size=2&gt; + &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt; + &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1&lt;/FONT&gt;&lt;FONT size=2&gt; &lt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;maxLength&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; += &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt; + &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLineLength&lt;/FONT&gt;&lt;FONT size=2&gt; += (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt; + &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;1&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;else&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/P&gt;
&lt;P&gt;{ &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Lines&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Add&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLineLength&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentWord&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt;} &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt; != &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Lines&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Add&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentLine&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;textLinesStr&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Lines&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Count&lt;/FONT&gt;&lt;FONT size=2&gt;]; &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Lines&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;CopyTo&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;textLinesStr&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;); &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;textLinesStr&lt;/FONT&gt;&lt;FONT size=2&gt;; &lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=66765"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=66765" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/66765.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2006/01/23/c-sharp-word-wrap-function-dotnet.aspx</guid>
            <pubDate>Mon, 23 Jan 2006 17:42:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/66765.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2006/01/23/c-sharp-word-wrap-function-dotnet.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/66765.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/66765.aspx</trackback:ping>
        </item>
        <item>
            <title>Accessing columns collection via the private autoGenColumnsArray property in a DataGrid</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2005/10/25/datagrid_columns_collection_autogencolumnsarray_reflection.aspx</link>
            <description>&lt;!--StartFragment --&gt; I have seen several people looking for a way to access the Columns&lt;BR&gt;collection when using the AutoGenerate = true option. Some&lt;BR&gt;people have gotten so far as to find the private autoGenColumnsArray&lt;BR&gt;that has the information, but we as developers have no way to access&lt;BR&gt;this information.&lt;BR&gt;&lt;BR&gt;I have come up with a solution for the problem, (as I am sure many&lt;BR&gt;others have) using reflection. Here is some sample code that will&lt;BR&gt;print out the auto generated column names from a datagrid.&lt;BR&gt;&lt;BR&gt;As stated, this code uses reflection. Reflection is slow. It might not&lt;BR&gt;also be allowed depending on your system's security settings. Also, if&lt;BR&gt;MS changes the internal structure of the DataGrid, this might break.&lt;BR&gt;(We are breaking encapsulation)&lt;BR&gt;&lt;BR&gt;Provided, is a function that will generically allow you to get the&lt;BR&gt;value of any private member of a class using reflection.&lt;BR&gt;&lt;BR&gt;Sorry about the formatting, I dont know a good way to format code for&lt;BR&gt;usenet. Visual Studio should clean up the code just find for you tho.&lt;BR&gt;&lt;BR&gt;&lt;CODE&gt;&lt;BR&gt;DataGrid dg = new DataGrid();&lt;BR&gt;dg.DataSource =new DataTable();// (Run some query or whatnot here)&lt;BR&gt;dg.DataBind&lt;BR&gt;&lt;BR&gt;ArrayList AutoGeneratedColumns&lt;BR&gt;= (ArrayList) GetPrivateField(dg,"autoGenColumnsArray"&lt;WBR&gt;) ;&lt;BR&gt;&lt;BR&gt;if (AutoGeneratedColumns!= null)&lt;BR&gt;foreach (DataGridColumn CurrentColumn in AutoGeneratedColumns)&lt;BR&gt;{&lt;BR&gt;Response.Write(CurrentColumn.HeaderText)&lt;WBR&gt;;&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;public static object GetPrivateField(object PassedObject, string&lt;BR&gt;FieldName)&lt;BR&gt;{&lt;BR&gt;&lt;BR&gt;object Field=null;&lt;BR&gt;&lt;BR&gt;if (PassedObject == null)&lt;BR&gt;throw new ArgumentNullException("PassedObject"&lt;BR&gt;,"PassedObject must be an instantiated object.");&lt;BR&gt;&lt;BR&gt;if (FieldName == null || FieldName.Trim() == "")&lt;BR&gt;throw new ArgumentOutOfRangeException("FieldName"&lt;BR&gt;,"Fieldname must be a non empty string.");&lt;BR&gt;&lt;BR&gt;Type ObjectType = PassedObject.GetType();&lt;BR&gt;System.Reflection.FieldInfo PrivateField =&lt;BR&gt;ObjectType.GetField(FieldName&lt;BR&gt;,System.Reflection.BindingFlags.Instance&lt;BR&gt;| System.Reflection.BindingFlags.NonPublic&lt;BR&gt;| System.Reflection.BindingFlags.Public&lt;BR&gt;| System.Reflection.BindingFlags.IgnoreCas&lt;WBR&gt;e);&lt;BR&gt;&lt;BR&gt;if (PrivateField == null)&lt;BR&gt;throw new ArgumentOutOfRangeException("FieldName"&lt;BR&gt;, ObjectType.FullName + " does not have a field : " + FieldName +&lt;BR&gt;".");&lt;BR&gt;&lt;BR&gt;Field = PrivateField.GetValue(PassedObject);&lt;BR&gt;return Field;&lt;BR&gt;}&lt;/CODE&gt; &lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=58096"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=58096" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/58096.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2005/10/25/datagrid_columns_collection_autogencolumnsarray_reflection.aspx</guid>
            <pubDate>Wed, 26 Oct 2005 07:01:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/58096.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2005/10/25/datagrid_columns_collection_autogencolumnsarray_reflection.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/58096.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/58096.aspx</trackback:ping>
        </item>
        <item>
            <title>Getting human readable values out of an enum.</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2005/10/20/57514.aspx</link>
            <description>&lt;P&gt;I found a post on &lt;A href="http://blogs.msdn.com/abhinaba/archive/2005/10/20/483000.aspx"&gt;Abhinaba's Blog&lt;/A&gt; talking about a cool way to override ToString on an enum to get human readable values out of it. I like the atributes, but have my own solution below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;In the past I have used a function that converts the enum strings to human strings.&amp;nbsp; This code relies on the developer using good naming standards for the enum values. But if you can't rely on that, you couldn't rely on them to put in the attribute values either, so I call it a wash.&lt;/P&gt;
&lt;P&gt;I have another function that you can pass an enum type, and it will populate a drop down list from the enum, using the int value for the list values, and the text description (passed through this function) for the text value.&lt;/P&gt;
&lt;P&gt;I may try to unify the two solutions, so that the attributes are provided, but the strings are generated automatically.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;FixEnumString&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;s&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;""&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;StringBuilder&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;sb&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;StringBuilder&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;s&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;foreach&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;char&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;c&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;s&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;sb&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Length&lt;/FONT&gt;&lt;FONT size=2&gt; != &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;c&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToString&lt;/FONT&gt;&lt;FONT size=2&gt;()!=&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;c&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToString&lt;/FONT&gt;&lt;FONT size=2&gt;().&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToLower&lt;/FONT&gt;&lt;FONT size=2&gt;())&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;sb&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Append&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;sb&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Append&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;c&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;sb&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToString&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"I D"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"ID"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;"_"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Replace&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;" "&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;output&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;static&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;PopulateDropDownListBoxFromEnum&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DropDownList&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;list&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;System&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Type&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;enumType&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;list&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Items&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Clear&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;foreach&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumValueObject&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;System&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Enum&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;GetValues&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;enumType&lt;/FONT&gt;&lt;FONT size=2&gt;))&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumValue&lt;/FONT&gt;&lt;FONT size=2&gt; = (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumValueObject&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumText&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;= &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumValueObject&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToString&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumText&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;FixEnumString&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumText&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;//currentEnumText = Translator.TranslateText(currentEnumText);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;list&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Items&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Add&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ListItem&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumText&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;currentEnumValue&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt;.&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ToString&lt;/FONT&gt;&lt;FONT size=2&gt;()));&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=57514"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=57514" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/57514.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2005/10/20/57514.aspx</guid>
            <pubDate>Thu, 20 Oct 2005 17:38:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/57514.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2005/10/20/57514.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/57514.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/57514.aspx</trackback:ping>
        </item>
        <item>
            <title>Solution : How to handle null values (especially date time) in a c# web service</title>
            <link>http://geekswithblogs.net/gaijin42/archive/2005/10/18/null_value_datetime_c_sharp_web_service_java_interop_hetrogeneous.aspx</link>
            <description>&lt;P&gt;Here is another programming blog entry. Sorry for the normal friends :)&lt;/P&gt;
&lt;P&gt;I recently ran into a problem with a web service I was trying to call from c# where the web service returned null dates (and other null values on elements that end up de-serialized as value types)&lt;/P&gt;
&lt;P&gt;I didn't find any good solutions online (other than wait for nullable types in c# 2.0 or change the service, neither of which was applicable in my situation)&lt;/P&gt;
&lt;P&gt;I ended up working out a solution with microsoft, and here it is. The following class will loop through a returned soap call, and set any datetime fields that are null to be DateTime.MinDate&lt;/P&gt;
&lt;P&gt;This can easily be extended to enable any other fields that need default values (enums, etc)&lt;/P&gt;
&lt;P&gt;To use this class, edit the reference.cs file that is generated by .net, and add this decoration to each webMethod call that you want to apply the fix to.&lt;/P&gt;
&lt;P&gt;[SoapFixer.SoapFixer()]&lt;/P&gt;
&lt;P&gt;for example, one of my functions looks like this :&lt;/P&gt;
&lt;P&gt;[System.Web.Services.Protocols.SoapHeaderAttribute("AuthenticationInfoValue")]&lt;BR&gt; [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:HPD_Help_Desk/OpGetList", RequestNamespace="urn:HPD_Help_Desk", ResponseNamespace="urn:HPD_Help_Desk", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]&lt;BR&gt;[return: System.Xml.Serialization.XmlElementAttribute("getListValues")]&lt;BR&gt;[SoapFixer.SoapFixer()]&lt;BR&gt;        public GetListOutputMapGetListValues[] OpGetList(string Qualification) {&lt;BR&gt;            object[] results = this.Invoke("OpGetList", new object[] {&lt;BR&gt;                        Qualification});&lt;BR&gt;            return ((GetListOutputMapGetListValues[])(results[0]));&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;The SoapFixer class decends from SoapExtensionAttribute, which makes all the magic happen. The class loops through each node in the returned XML, and uses reflection to find the appropriate field in the destination class. If the destination field is a datetime, and the value is null, the value is converted to MinDate (1/1/0001)&lt;/P&gt;
&lt;P&gt;The field lookup starts out by assuming that the node name in the xml is identical to the class field name. However, this is not always true.  In some cases (notably where the XML element name is an invalid field name, like it has a - in it)   they are not the same. In this case, the field is decorated with a XmlElementAttribute attribute that specifies the real name. The GetFieldInfo function(s) try to grab the field name assuming an exact match, and if that fails tries to grab the attributes and get a match that way. Any fields that are not found are written out to the console.&lt;/P&gt;
&lt;P&gt;using System;&lt;BR&gt;using System.IO;&lt;BR&gt;using System.Web;&lt;BR&gt;using System.Web.Services.Protocols;&lt;BR&gt;using System.Web.Services.Description;&lt;BR&gt;using System.Xml;&lt;BR&gt;using Rockwell.Library.RemedyWebService;&lt;BR&gt;using System.Reflection;&lt;BR&gt;using System.Xml.Serialization;&lt;/P&gt;
&lt;P&gt;namespace Rockwell.Library.DataAccessor.Reusable&lt;BR&gt;{&lt;BR&gt;    /// &lt;SUMMARY&gt;&lt;BR&gt;    /// Summary description for CaptureSoap.&lt;BR&gt;    /// &lt;/SUMMARY&gt;&lt;BR&gt;    [AttributeUsage(AttributeTargets.Method)]&lt;BR&gt;    public class RemedySoapFixer : SoapExtensionAttribute&lt;BR&gt;    {&lt;BR&gt;        private int m_Priority = 0;&lt;/P&gt;
&lt;P&gt;        public override Type ExtensionType&lt;BR&gt;        {&lt;BR&gt;            get&lt;BR&gt;            {&lt;BR&gt;                return typeof(DeleteDate);&lt;BR&gt;            }&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        public override int Priority&lt;BR&gt;        {&lt;BR&gt;            get&lt;BR&gt;            {&lt;BR&gt;                return m_Priority;&lt;BR&gt;            }&lt;BR&gt;            set&lt;BR&gt;            {&lt;BR&gt;                m_Priority = value;&lt;BR&gt;            }&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;    }&lt;/P&gt;
&lt;P&gt;    public class DeleteDate : SoapExtension&lt;BR&gt;    {&lt;BR&gt;        private Stream soapStream;&lt;BR&gt;        private Stream customStream;&lt;BR&gt;//Switch this to be your destination field type. (IE, the return value of your web method)&lt;BR&gt;        static GetListOutputMapGetListValues exampleItem = new GetListOutputMapGetListValues(); &lt;/P&gt;
&lt;P&gt;        static FieldInfo[] fields = ((object)exampleItem).GetType().GetFields();&lt;/P&gt;
&lt;P&gt;        public override object GetInitializer(Type serviceType)&lt;BR&gt;        {   &lt;BR&gt;            return GetType();&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)&lt;BR&gt;        {&lt;BR&gt;            return null;&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        public override void Initialize(object initializer)&lt;BR&gt;        {&lt;/P&gt;
&lt;P&gt;        }&lt;/P&gt;
&lt;P&gt;        public override Stream ChainStream(Stream stream)&lt;BR&gt;        {&lt;BR&gt;            soapStream = stream;&lt;BR&gt;            customStream = new MemoryStream();&lt;BR&gt;            return customStream;&lt;BR&gt;        }&lt;BR&gt;       &lt;BR&gt;        public override void ProcessMessage(SoapMessage message)&lt;BR&gt;        {&lt;BR&gt;            switch(message.Stage)&lt;BR&gt;            {&lt;BR&gt;                case SoapMessageStage.BeforeSerialize:                   &lt;BR&gt;                    break;&lt;BR&gt;                case SoapMessageStage.AfterSerialize:&lt;BR&gt;                    ChangeOutgoingSoap(message);&lt;BR&gt;                    break;&lt;BR&gt;                case SoapMessageStage.BeforeDeserialize:&lt;BR&gt;                    ChangeIncomingSoap(message);&lt;BR&gt;                    break;&lt;BR&gt;                case SoapMessageStage.AfterDeserialize:&lt;BR&gt;                    break;&lt;BR&gt;                default:&lt;BR&gt;                    break;&lt;BR&gt;            }&lt;BR&gt;        }&lt;BR&gt;           &lt;BR&gt;   &lt;BR&gt;        public void ChangeOutgoingSoap(SoapMessage message)&lt;BR&gt;        {&lt;BR&gt;            //reads the content of the customStream&lt;BR&gt;            //modify it, log it, whatever&lt;BR&gt;            //and write it to soapStream&lt;/P&gt;
&lt;P&gt;            Stream tempstream = new MemoryStream();&lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;            Copy (customStream,tempstream);&lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;            tempstream.Position = 0;&lt;BR&gt;            XmlDocument doc = new XmlDocument();&lt;BR&gt;            doc.Load(tempstream);&lt;BR&gt;            //modify outgoing XML here&lt;BR&gt;            //doc.GetElementsByTagName("elementname").Item(0).InnerText = "whatever";&lt;BR&gt;            doc.Save(customStream);   &lt;BR&gt;   &lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;            Copy(customStream, soapStream);&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        public void ChangeIncomingSoap(SoapMessage message)&lt;BR&gt;        {&lt;BR&gt;            //reads the content of the soapStream&lt;BR&gt;            //modify it, log it, whatever&lt;BR&gt;            //and write it to customStream&lt;BR&gt;   &lt;BR&gt;            Copy(soapStream, customStream);&lt;BR&gt;            customStream.Position = 0;&lt;/P&gt;
&lt;P&gt;            Stream tempstream = new MemoryStream();&lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;            Copy (customStream,tempstream);&lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;            tempstream.Position = 0;&lt;BR&gt;            XmlDocument doc = new XmlDocument();&lt;BR&gt;            doc.Load(tempstream);&lt;BR&gt;  &lt;BR&gt;            FixNodes(doc);&lt;BR&gt;           &lt;BR&gt;         &lt;BR&gt;            doc.Save(customStream);&lt;BR&gt;            customStream.Position = 0;&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;        public FieldInfo GetFieldInfo(object target, string fieldName)&lt;BR&gt;        {&lt;BR&gt;            if (target == null)&lt;BR&gt;                throw new ArgumentNullException("target", "target must be an instantiated object.");&lt;/P&gt;
&lt;P&gt;            if (fieldName == null || fieldName.Trim().Length==0)&lt;BR&gt;                throw new ArgumentOutOfRangeException("fieldName", "Fieldname must be a non empty string.");&lt;/P&gt;
&lt;P&gt;           &lt;BR&gt;       &lt;BR&gt;            Type objectType = target.GetType();&lt;/P&gt;
&lt;P&gt;           &lt;BR&gt;           &lt;/P&gt;
&lt;P&gt;            FieldInfo privateField = objectType.GetField(fieldName,&lt;BR&gt;                BindingFlags.Instance&lt;BR&gt;                | BindingFlags.NonPublic&lt;BR&gt;                | BindingFlags.Public&lt;BR&gt;                | BindingFlags.IgnoreCase&lt;BR&gt;                | BindingFlags.FlattenHierarchy&lt;BR&gt;               &lt;BR&gt;                );&lt;/P&gt;
&lt;P&gt;           &lt;BR&gt;            if (privateField == null)&lt;BR&gt;                throw new ArgumentOutOfRangeException("FieldName", objectType.FullName + " does not have a field : " + fieldName + ".");&lt;/P&gt;
&lt;P&gt;            return privateField;&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        private FieldInfo GetFieldInfo(XmlNode node)&lt;BR&gt;        {&lt;BR&gt;            if (node.Name =="xml"&lt;BR&gt;                || node.Name =="#text")&lt;BR&gt;                return null;&lt;/P&gt;
&lt;P&gt;            FieldInfo fieldInfo = null;&lt;BR&gt;            try&lt;BR&gt;            {&lt;BR&gt;                fieldInfo = GetFieldInfo(exampleItem, node.Name);&lt;BR&gt;            }&lt;BR&gt;            catch(ArgumentOutOfRangeException)&lt;BR&gt;            {&lt;BR&gt;                foreach (FieldInfo currentFieldInfo in fields)&lt;BR&gt;                {&lt;BR&gt;                    if (currentFieldInfo.Name == node.Name)&lt;BR&gt;                        fieldInfo = currentFieldInfo;&lt;BR&gt;                   &lt;BR&gt;                    if (fieldInfo==null)&lt;BR&gt;                    {&lt;BR&gt;                       object[] attributes = currentFieldInfo.GetCustomAttributes(false);&lt;BR&gt;                        foreach (object currentAttribute in attributes)&lt;BR&gt;                        {&lt;BR&gt;                          &lt;BR&gt;                            XmlElementAttribute currentElementAttribute;&lt;BR&gt;                            currentElementAttribute = currentAttribute as XmlElementAttribute;&lt;BR&gt;                            if (currentElementAttribute!=null)&lt;BR&gt;                            {&lt;BR&gt;                                if (currentElementAttribute.ElementName == node.Name)&lt;BR&gt;                                   fieldInfo = currentFieldInfo;&lt;BR&gt;                            }&lt;BR&gt;                        }&lt;BR&gt;                    }&lt;/P&gt;
&lt;P&gt;                }&lt;BR&gt;       &lt;BR&gt;            }&lt;BR&gt;            return fieldInfo;&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        private void FixNodes (XmlNode node)&lt;BR&gt;        {&lt;BR&gt;            foreach (XmlNode childNode in node.ChildNodes)&lt;BR&gt;            {&lt;BR&gt;                FixNodes (childNode);&lt;BR&gt;            }&lt;/P&gt;
&lt;P&gt;            FieldInfo fieldInfo = GetFieldInfo(node);&lt;/P&gt;
&lt;P&gt;            if (fieldInfo!=null)&lt;BR&gt;            {&lt;BR&gt;                if (fieldInfo.FieldType ==typeof(DateTime))&lt;BR&gt;                   &lt;BR&gt;                {&lt;BR&gt;                    if (node.InnerText.Length==0)&lt;BR&gt;                        node.InnerText = "0001-01-01T00:00:00-06:00";&lt;BR&gt;                    else&lt;BR&gt;                    {&lt;BR&gt;                        DateTime dt;&lt;BR&gt;                        try&lt;BR&gt;                        {&lt;BR&gt;                            dt = DateTime.Parse(node.InnerText);&lt;BR&gt;                        }&lt;/P&gt;
&lt;P&gt;                        catch (FormatException)&lt;BR&gt;                        {&lt;BR&gt;                            Console.WriteLine ("{0}, {1}", node.Name, node.InnerText);&lt;BR&gt;                            node.InnerText = "0001-01-01T00:00:00-06:00";&lt;/P&gt;
&lt;P&gt;                        }&lt;BR&gt;                    }&lt;BR&gt;                }&lt;/P&gt;
&lt;P&gt;             &lt;BR&gt;       &lt;BR&gt;       &lt;BR&gt;           &lt;BR&gt;            }&lt;BR&gt;            else&lt;BR&gt;            {&lt;BR&gt;            if (node.Name!="#text")&lt;BR&gt;                Console.WriteLine("field not found for {0}", node.Name);&lt;BR&gt;            }&lt;BR&gt;        }&lt;/P&gt;
&lt;P&gt;        private void Copy(Stream from, Stream to)&lt;BR&gt;        {&lt;BR&gt;            TextReader reader = new StreamReader(from);&lt;BR&gt;            TextWriter writer = new StreamWriter(to);&lt;BR&gt;            writer.WriteLine(reader.ReadToEnd());&lt;BR&gt;            writer.Flush();&lt;BR&gt;        }&lt;BR&gt;       &lt;BR&gt;    }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=57332"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=57332" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/gaijin42/aggbug/57332.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Coyne</dc:creator>
            <guid>http://geekswithblogs.net/gaijin42/archive/2005/10/18/null_value_datetime_c_sharp_web_service_java_interop_hetrogeneous.aspx</guid>
            <pubDate>Wed, 19 Oct 2005 08:07:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/gaijin42/comments/57332.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/gaijin42/archive/2005/10/18/null_value_datetime_c_sharp_web_service_java_interop_hetrogeneous.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/gaijin42/comments/commentRss/57332.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/gaijin42/services/trackbacks/57332.aspx</trackback:ping>
        </item>
    </channel>
</rss>