Welcome

You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

Tip: CheckedListBox and ComboBox Programmatic Binding

Posted by Keith Elder | Posted in .Net, Smart Clients | Posted on 03-11-2006

0

At some point in your career as a software engineer you are going to run across the need to build your forms dynamically.  Whether you read information from a database, dataset, or xml file.  Recently I was working on a new feature for our internal Smart Client application whereby we can add new fields into the database for our application and have the new field show up in the appropriate screen and auto validate itself.  The feature itself when complete is going to be very cool and allow us to add new form fields at will without having to get a database engineer or anyone involved. 

 

The Problem

I ran across a problem this week that stumped me for a bit while trying to generate CheckedListBox and ComboBox controls on my UserControl.  Here is a pseudo example of the code for educational purposes:

 

    1  public partial class Form1 : Form

    2     {

    3         SubtextDataDataSet _dsBlog = new SubtextDataDataSet();

    4 

    5         public Form1()

    6         {

    7             InitializeComponent();

    8             // get data

    9             SubtextDataDataSetTableAdapters.subtext_ContentTableAdapter ta = new WindowsApplication1.SubtextDataDataSetTableAdapters.subtext_ContentTableAdapter();

   10             _dsBlog.Merge(ta.GetData());

   11         }

   12 

   13         private void Form1_Load(object sender, EventArgs e)

   14         {

   15             CheckedListBox chkListBox = new CheckedListBox();

   16             chkListBox.Name = “BlogEntries”;

   17             chkListBox.Sorted = true;

   18             chkListBox.DataSource = _dsBlog.subtext_Content;

   19             chkListBox.DisplayMember = “Title”;

   20             chkListBox.ValueMember = “ID”;

   21             chkListBox.Location = new Point(12, 12);

   22             chkListBox.Size = new Size(289, 219);

   23             chkListBox.CheckOnClick = true;

   24 

   25             for (int i = 0; i < chkListBox.Items.Count; i++)

   26             {

   27                 if (i % 2 == 0)

   28                 {

   29                     chkListBox.SetItemCheckState(i, CheckState.Checked);

   30                 }

   31             }

   32             this.Controls.Add(chkListBox);

   33         }

   34     }

 In the above example we have a DataSet that we are reading in the posts to our blog.  I’ve been playing with SubText lately so I decided to use this.   Lines 15-23 are fairly simple whereby we create the control and then bind our DataSource to our control.  Lines 25-31 is where the problem is.  Even though we’ve bound our control to our DataSet, there is nothing in the chkListBox.Items collections.  If we run this code, here is what we’ll see:

Form1

What you notice right away is every other item is not checked (although you think they would be).  Even though our data is getting bound to our control the DataSource we’ve declared does not get moved into the Items collection of the control until it gets rendered. 

The Solution

After struggling with this for awhile the solution to this problem is a one liner.  Most solutions are 🙂  The answer is instantiate the BindingContext of the control.  After the data is bound to the control the following needs to be called:

 

chkListBox.BindingContext = new BindingContext();

After adding this line into our code and rebuilding the solution we can see we get the results we originally wanted.  

Form2

For those that run into this issue I hope this post helps you.  I know that I searched every known search engine known to man kind and didn’t find a clear example nor explanation how to fix the problem.   I also should note that even though the DataSource, DisplayMember and ValueMember properties do not show up in intellisense in Visual Studio, they are in fact there!  Happy Coding. – The Elder

SubText vs DasBlog (Part 1)

Posted by Keith Elder | Posted in .Net, Asp.Net | Posted on 30-10-2006

6

This weekend I spent some time investigating two of the top blog packages: SubText and DasBlog in preparing for a new site I launched (http://www.keithelder.net).  I’ve heard of each app equally it seems and each seem to be the top two players in the .Net blog space.  After downloading both of them and poking around the source and trying to get them to build I am no where further along in my evaluation this evening than I was when I started. 

 

DasBlog Installation Stumps Me

For starters DasBlog is still using VS2003 for its solution.  For me, this was a huge turn off right out of the gate.   I had to configure lots more out of the box to get DasBlog configured.  Ultimately I had something configured improperly with IIS and kept getting this error:

 

Server Error in ‘/’ Application.


Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:

Line 109:        <!-- <httpCookies httpOnlyCookies="false"/> -->
Line 110:        
Line 111:        <authentication mode="Forms">
Line 112:			<!-- NOTE: If you want to run MULTIPLE dasBlogs on the SAME Domain Name
Line 113:			     include the path in each blog's Web.Config like path="/dasblog1" and path="/yoursite"

Source File: C:\Inetpub\wwwroot\DasBlog\source\newtelligence.DasBlog.Web\web.config    Line: 111

After a stint of digging around and trying to trouble shoot things I gave up and decided to try to get SubText going.  I honestly don’t care which one I wind up with but I ultimately want to use one that I can contribute too. 

SubText Installation Stumps Me

After getting defeated by the DasBlog installation I decided to give SubText a whirl.  As soon as I opened the solution I had errors.  While SubText works with VS2005, it requires you have the web project addition installed, which also requires a VS2005 update to be installed.  After going through all of the required updates I thought I was on my way when I pressed F5 in VS2005 and it launched a web site that took me to the installation pages as outlined in the videos.  It was here where things got shaky because I started running into dbo.subtext_version issues.  I pulled up RssBandit and went to Phil Haack’s blog and found this entry.   It turns out I wasn’t the only one that had a SQL Server installation problems.  It is late and I have to work on Monday so I am off to bed.  I plan on trying the update tomorrow evening and I’ll let you know how it goes. 

Alabama Code Camp Download Available

Posted by Keith Elder | Posted in .Net, Presentations, Smart Clients | Posted on 30-10-2006

0

Saturday was the Alabama Code Camp in Montgomery.  I didn’t get to blog about it too much since I spent most of my energy either updating my demos or driving (5 hour drive).  I finally got to meet Doug (the new DE for the area) as well as chat with a few of the other speakers (Bruce Thomas, Todd Miranda, Mark Dunn, Jeremy Chance (thanks for the ride!), Jim Wooley and William Howell),  at the speaker get together on Friday.   The turn out was really good, rumors are floating around 150 or so attended. 

It was also good to see some familiar faces from the Mobile User’s Group.  Several of them finally got to here the enterprise architecture session since we had to cut it short when I visited.

You can find all the material of the two sessions I did at http://keithelder.net/Presentations/DevelopingSmartClientAppsForEnterprise/Default.aspx.  This track will continue to grow and be updated as I add more material so stay tuned for updates.

TechEd 2007 Moved to Orlando

Posted by Keith Elder | Posted in .Net | Posted on 20-10-2006

0

As first noted by DevFish, Tech Ed 2007 is being moved to Orlando.  Previously it was going to be held in New Orleans.  This is kind of a bitter sweet move for me.  It is sweet because now I get to go fishing with DevFish since I got on the list first.  And it is bitter because instead of me driving 1.5 hours to New Orleans it is now a 595 mile trip.  Honestly I can’t say that I blame them for moving it.  New Orleans is just a wreck still (at least that is the word on the street here). 

Job Openings: .Net Engineers Needed

Posted by Keith Elder | Posted in .Net, Asp.Net | Posted on 27-09-2006

1

It isn’t everyday that you can say you work for #1 but I can.  Actually I have said that for the past 2 years.  Would you like to work for #1 as well? If you are a .Net Developer / Engineer who is passionate, self-motivated, loves being able to set and manage your own goals and you are looking to work for THE best company to work for in the IT industry in the US, we in turn are looking for you!

This is the first time I have tried posting job openings on my blog so we’ll see how this works.  If it works, great, if not, there was nothing lost. 

Quicken Loans is seeking talented .Net developers and engineers.  If you have some or all of the following skills, please contact me so I can get you started down the interview path.

  1. .Net Framework 2.0
  2. Visual Studio 2005
  3. Asp.Net
  4. Web Services
  5. Smart Client
    1. ClickOnce
    2. Winform experience
  6. Enterprise Library
  7. Smart Client Software Factory
  8. Web Service Software Factory
  9. Biztalk
  10. SQL Server 2005
  11. Reporting Services

I am sure you will check out our web site, and you should.  There is TONS of information about the company, the awards we’ve won, about our culture and our outstanding benefits.  If you want to find out more about us and what type of work you would be doing, CONTACT ME with the information found on the About page.  Call or email it doesn’t matter.  We are moving fast so act now while supplies last. 🙂