July 2007 - Blake Niemyjski

  • Repeater Control, Is it really that Dynamic?

     

    My question to everyone, Is the Repeater control dynamic enough to create custom tables on the fly? When I think of dynamic it's something you have complete control over. And can change the display at anytime during execution.  Please note that I'm sure there are multiple ways one can accomplish what I'm looking for, this is the way I choose to do it.

    The one thing about the repeater control is it's great for making data that has a unique predefined header and footer. The remaining data can be found in the body ("ItemTemplate, AlternatingItemTemplate...") and over all is dynamic. The data that is contained in the body is most of the time very similar in Size and Type. This is because the DataSource of the Repeater control takes any IEnumerable object. This IEnumerable object is a data structure. This data structure is 90%+ of the time displayed to the screen in a table or list because the developer knows what data that structure is going to contain.

    So now we have came to the conclusion that the repeater control is great for creating Predefined templates, but when about when you want to create Dynamic Templates on the fly. You're probably thinking that this is easy; one just has to create a Template class that derives from ITemplate.

    public class SomeOnesTemplate : ITemplate

    Inside this class if you don't create multiple template classes (one for Header, Item, and footer) you will have to check the the ListItemType.Item in ITemplate.InstantiateIn and then process the data.  One will quickly get this set up and get everything working in no time from here. But the templates are still not completely dynamic because the HeaderTemplate and FooterTemplate are not being passed any data.  

    In your custom Item templates you can do anything you want with the DataRowView (If the DataSource is a DataView) or DataRow.  The row of data is provided to you in your custom template by the repeater control, except for the HeaderTemplate and FooterTemplate.

    Apparently Microsoft does not want the user to access any rows of data, I can see their point, as in the row they would pass you would be the first row of actual data, however why can't they pass you a row with the column names? One can override this default behavior by implementing some more code. But please consider another thing before doing this. Not only does the HeaderTemplate not have access to any DataRow, All templates do not have access to the DataSource. So even if there was not a row of data being sent, one also does not have access to the DataSource.

    I think one of the reasons why the user can't access the DataSource inside any template is because .Net is iterating through the DataSource, and they do not want the Data to become corrupted. Also another point I would like to add. If one did implement it so you could get access to the DataSource, you would want to clone the IEnumerable object, thus creating a lot of overhead, because you're copying all the data for one simple operation. So there is no really good way around this if you wish to create everything in your Template class.

    The Work Around

    Here is one of the few ways there are to get around this issue. Remove the HeaderTemplate from your Template Class and overload the following methods:

    protected override void Render(HtmlTextWriter writer)

    public override void DataBind()

    You will want to create your headers markup dynamically in the DataBind method and then call base method of DataBind. You have full access to the DataSource, and from here you can do anything with the data. You could have something like this

    StringBuilder header = new StringBuilder();

    header.Append("<table><tbody><tr>");

    DataView dv = DataSource as DataView;

    if(dv != null)

    {

    foreach (DataColumn dc in dv.Table.Columns)

    {

    header.Append(string.Format("<th scope=\"col\">{0}</th>", dc.ColumnName));

    header.Append("</tr>")

    }

    return header.ToString();

     

    The next Step is to write the headers markup that you created before the repeater controls Body ("Item") and footer templates run. You can do this by adding the following code to the overridden Render method. HeaderMarkup is a property that stored the Header's html markup.

    writer.Write(HeaderMarkup);

    base.Render(writer);

    And that is how you can create a Dynamic Repeater control, to create custom templates. Now you can show or hide certain columns on the fly.

  • Visual Studio 2008: Smarter Intellisense

    Scott Guthrie showed off some new features that he's recently learned. This feature is new to Visual Studio and has been one that I have been waiting for since Visual Studio .NET 2003. Have you ever been typing and needed to look at something behind Intellisense?

    Intellisense

    It happens to me quite a bit since I started using Visual Studio .NET 2003.

    Intellisense

    Now while Intellisense is being displayed, one can hit the control key and the Intellisense becomes transparent. Once the control key is let up, it's restored to its previous state.

    Also, one new thing that Scott showed off was the ability to "Remove Unused Usings". This feature is included in the Visual Studio add-in ReSharper. However, Visual Studio 2008 takes it a step further and allows you to "Sort Usings", and "Remove and Sort".

    Usings

    Source ( Nice VS 2008 Code Editing Improvements )

  • Visual Studio 2008 beta 2

    Microsoft recently released its next beta version of Visual Studio 2008. Microsoft has targeted all types of users with the Visual Studio 2008 release by including an updated MSDN Library, Express, Standard, Professional and Enterprise versions of Beta 2. "With this beta release, Visual Studio 2008 is 99 percent complete, according to a Microsoft spokeswoman" (PC WORLD). Below is more information about the release of Visual Studio 2008 Beta 2 and where you can download it. PLEASE BE SURE TO READ THE IMPORTANT INSTUCTIONS BEFORE INSTALLING!!!

    "VS 2008 Multi-Targeting Support

    VS 2008 enables you to build applications that target multiple versions of the .NET Framework.  You can learn more about how this works from my blog post here:

    VS 2008 Web Designer and CSS Support

    VS 2008 includes a significantly improved HTML web designer.  This delivers support for split-view editing, nested master pages, and great CSS integration.  Below are two articles I've written that discuss this more:

    ASP.NET also has a new <asp:ListView> control that I'll be blogging about in the near future.  It delivers very flexible support for data UI scenarios, and allows full customization of the markup emitted.  It works nicely with the new CSS support in VS 2008.

    ASP.NET AJAX and JavaScript Support

    .NET 3.5 has ASP.NET AJAX built-in (and adds new features like UpdatePanel support with WebParts, WCF support for JSON, and a number of bug fixes and performance improvements).  VS 2008 also has great support for integrating JavaScript and AJAX into your applications:

    I will be doing a blog post in the next few days that talks more about some of the ASP.NET AJAX specific improvements, as well as how to upgrade existing ASP.NET AJAX 1.0 applications to use them.

    Language Improvements and LINQ

    The new VB and C# compilers in VS 2008 deliver significant improvements to the languages.  Both add functional programming concepts that enable you to write cleaner, terser, and more expressive code.  These features also enable a new programming model we call LINQ (language integrated query) that makes querying and working with data a first-class programming concept with .NET. 

    Below are some of the articles I've written that explore these new language features using C#:

    Data Access Improvements with LINQ to SQL

    LINQ to SQL is a built-in OR/M (object relational mapper) in .NET 3.5.  It enables you to model relational databases using a .NET object model.  You can then query the database using LINQ, as well as update/insert/delete data from it.  LINQ to SQL fully supports transactions, views, and stored procedures.  It also provides an easy way to integrate business logic and validation rules into your data model.  Below are some of the articles I've written that explore how to use it:

    I'll be adding several more articles to my series above in the weeks ahead.  I think you'll find that LINQ to SQL makes it dramatically easier to build much cleaner data models, and write much cleaner data code.

    Lots of other improvements

    The list above is only a small set of the improvements coming.  For client development VS 2008 includes WPF designer and project support.  ClickOnce and WPF XBAPs now work with FireFox.  WinForms and WPF projects can also now use the ASP.NET Application Services (Membership, Roles, Profile) for roaming user data. Office development is much richer - including support for integrating with the Office 2007 ribbon.  WCF and Workflow projects and designers are included in VS 2008.  Unit testing support is now much faster and included in VS Professional (and no longer just VSTS).  Continuous Integration support is now built-in with TFS.  AJAX web testing (unit and load) is now supported in the VS Test SKU.  And there is much, much more...

    Important Installation Notes - PLEASE READ!

    There are two important things you should do immediately after installing VS 2008 and .NET 3.5 Beta2:

    1) You should download and run this batch file.  This takes only a few seconds to run, and fixes an issue we found earlier this week with the version policy of System.Web.Extensions.dll - which is the assembly that contains ASP.NET AJAX.  If you don't run this batch file, then existing ASP.NET 2.0 projects built with ASP.NET AJAX 1.0 and VS 2005 will end up automatically picking up the new version of ASP.NET AJAX that ships in .NET 3.5 Beta2.  This will work and run fine - but cause you to inadvertently introduce a .NET 3.5 dependency in the applications you build with VS 2005.  Running the batch file will change the version binding policy of the new System.Web.Extensions.dll assembly and ensure that you only use the new .NET 3.5 ASP.NET AJAX version with projects that you are explicitly building for .NET 3.5.

    2) If you have ever installed a previous version of "Orcas" or VS 2008 on your machine (either Beta1 or one of the CTP versions), you need to reset your VS 2008 settings after installing Beta2.  If you don't do this, you'll have an odd set of settings configured (some windows will be in the wrong place), and you'll potentially see some IDE performance slowness.  You can reset your settings by typing "DevEnv /resetsettings" on the command-line against the VS 2008 version of the IDE" (Scott Guthrie)

    System Requirements needed to run Visual Studio 2008:

    • Supported Operating Systems: Windows Server 2003; Windows Vista; Windows XP
    • Processor: 1.6GHz Pentium III+
    • RAM: 1 GB of available physical RAM

       

    Download ( Visual Studio 2008 White Paper )

    Download ( Visual Studio 2008 )

    Download ( Visual Studio 2008 Express Versions )

  • Cryptography!

    I had so much fun last night, Jason Alexander is so awesome. He took us to Dave and Busters last night! I think I had the most fun out of everyone there (Interns, Jason, Rob, and Snelson Stopped by for a minute).   I’ve really never been to a place that big before, the only place that I’ve been to that was even remotely in the same category was chucky cheese in like 4th grade.  I definitely had a good time, and walked away with around 4600 tickets! When I was checking out, all I could think about was math and what I could get for my nephews and niece, while at the same time having something small left over for myself and others.

    It was pretty amazing on how quickly I picked up on recognizing patterns.  I think this was the reason I was winning the jackpots left and right. I guess that’s one thing math has taught me; to find patterns and study them. Currently I’m reading a number theory book that’s really good.  One of my instructors back at school lent me the book for the summer; he said that I would be interested in this book.  He was pretty right. This all came about when I had started talking to him about cryptography during the end of the year.  While in that conversation he told me that he had studied cryptography while he was in school. I thought that was pretty cool! There has always been something about cryptography that I find so interesting; that it has made me start to really appreciate math. For those of you who don’t know a lot about me. I’m currently double majoring in Computer Science and Mathematics.

    Today, Rob Howard gave us a review; it went pretty good. We came across one or two small things that we need to work on. Overall we are sitting pretty well, and I’m glad the code base is where it is at this point in the game.

  • The Rules of Subversion (SVN)!

    I had quite the experience today, for one I committed the Community Server Enterprise Reporting Installer into the Repository of Community Sever's Installer. EEK!  So I quickly did a "revert" on the folder to what it previously was before I had changed anything.

    So here is the story on how it all happened.  A few days ago I grabbed down the newest Community Server revision off of svn and copied the installer folder from CS into our project and started rewriting the installer for our project. Thanks to hidden .svn folders and files when I hit commit button today. The data stored in the hidden .svn folder told it to add it to the CS SVN and not the CSER SVN. Luckily Telligent was using source control so I could rollback my commit and get it committed to the right place.

    Whenever you need to copy files from one svn repository to another svn repository make sure that you do a "Check out" so it removes the hidden svn directories.

  • Community Server Enterprise Reporting Release Date

    Telligent let the word out and posted a release date on CommunityServer.org.  Around September 1st we will be releasing beta one of Community Server Enterprise Reporting.  For the past two days I have been working on the installer for Community Server Enterprise Reporting.  Hopefully tomorrow morning I'll finish the small little bit of work that still needs to be done. That is if nothing else jumps out at me!

    Around noon, nine of us went out to Purple Cow for lunch. Half of us got lost while trying to find it. Jason Alexander and Delia Johnson thought Purple Cow was near the Dallas Tollway. Thanks to Kevin Clark's vast knowledge of Bovines, we found the watering hole in time for grub. (I think I'm starting to talk like a Texan :\ JK).  Delia quickly gave me the information that I needed "Just pick whatever Jason's getting. He always picks the best on the menu." Let me tell you, we got pretty wasted off that advice, 15 shots each... later... we were all ready to break the build! JUST KIDDING! I ended up getting the same as Jason and Delia, which was a meatloaf sandwich with fries and water. I might add that it was pretty delicious, and wouldn't mind going back to Purple Cow!

  • Oh Snap!

    Today I heard a few words being yelled out into the hallway from a fellow intern. When this happens, I always take the time off and investigate because I know something has gone wrong. In this case, Andrew broke the build again today.

    The build breaker wasn't a programming bug, he just forgot to close visual studio, so it never saved the project file. This caused the build to break because the project file contains what's included in the project. When he forgot to update the project file (the project file that says don't include this file because file XXX.XXX was deleted), it wasn't committed, thus causing the build to break on our machines.

    I started working on making the Community Server Enterprise Reporting Web Installer.  It's taking a bit longer to complete than I expected it would take. Rob Howard put up some small snapshots of our project on his blog; so go check them out.

1 2 3 4 Next >
windowscoding.com;
Copyright © 2008 Windows Coding
Microsoft and Microsoft logo's are trademarks of Microsoft Corporation.