Wednesday, June 20, 2007

I have been using this little piece of code to recursively search my control collections for a given control or type of controls and thought that it might be of some use to others. The general purpose utility code is here:

public static void SearchControls(ControlCollection controls, Action<Control> action)

{

    foreach (Control control in controls)

    {

        if (control.HasControls())

        {

            SearchControls(control.Controls, action);

        }

        action(control);

    }

}

 

For example, if you want to search for and Trim() all TextBox controls within a GridView, you could call the routine as follows using an anonymous method:

 

SearchControls(GridViewJobs.Controls, delegate(Control control)

{

    TextBox textBox = control as TextBox;

    if (textBox != null)

    {

        textBox.Text = textBox.Text.Trim();

    }

});

 

If you need to search a GridView footer for a drop down list, you call the code as follows:

 

ControlUtility.SearchControls(gvwOrganizations.FooterRow.Controls, delegate(Control control)

{

    DropDownList dropDownListCategory = control as DropDownList;

    if (dropDownListCategory != null)

    {

        categoryID = int.Parse(dropDownListCategory.SelectedValue);

    }

});

 

 

kick it on DotNetKicks.com   Wednesday, June 20, 2007 8:01:19 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, May 22, 2007

As much as I like to think that Comcast is at the center of the evil empire, they do on occasion come through.

Today I went into my local Comcast office to upgrade my service now that I have an HD TV. As expected, there is no change to my monthly bill to get HD service. They did ding me for $10 or $12 / month to get the Discovery Channel in HD which I felt was kind of a marketing gimmick. Discovery is the premier HD channel and not including it in their basic package makes for an easy up sell.

30 seconds later, their service person handed me my new cable box with a set of component video cables. I quickly remembered that I needed a set of component cables for my DVD which previously connected to my old TV using s-video. I asked if I could get a second set of cables? Sure. Then I noticed that the cable box had a DVI connector on it but no HDMI. Could I get a DVI to HDMI converter cable? (I konw DVI and HDMI are pin compatable but that cable would have cost me $30 at one of the local big box stores.) Sure here is your HDMI / DVI cable. She apologized for not having an audio cable that I could have. I walked out of there with at least $50 worth of cables. The experience was entirely about making sure that I had everything I needed to make my TV work. I felt pretty good about the whole thing.

 

kick it on DotNetKicks.com   Tuesday, May 22, 2007 1:10:35 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, May 08, 2007

Over the weekend, Moby and Aaron both hit big milestones:

 

Moby is now 15 years old. Doing great. He still gets himself up on our bed every morning. Nemo is also doing well and is 14.)

 

Aaron is now 9 months old and crawling and has also figured out how to get himself into our bed every morning but requires a bit of help.

kick it on DotNetKicks.com   Tuesday, May 08, 2007 7:21:21 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Saturday, April 28, 2007

I came across this (in an asp.net page) last week:

protected void Page_Load(object sender, EventArgs e) {

    System.Windows.Forms.MessageBoxButtons buttons = System.Windows.Forms.MessageBoxButtons.YesNo;

    System.Windows.Forms.DialogResult result;

 

    result = System.Windows.Forms.MessageBox.Show("Test Message", "Test Caption", buttons);

}

 

kick it on DotNetKicks.com   Saturday, April 28, 2007 5:32:48 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Friday, April 27, 2007

I can't tell you how many times I have struggled with where to store a data item in a Check Box control. I typically need to do this when dynamically generating a series of check boxes on a page that correspond to a data item. I have used the tool tip which works ok but exposes your data to the use when the hover over the control. I have seen others manipulate part of the control ID to contain a data item but this seems problematic. Then it came to me:

using System;

 

namespace Utility {

 

    public class CheckBox: System.Web.UI.WebControls.CheckBox {

 

        public CheckBox() { }

 

        public object Data {

            get { return ViewState["Data"]; }

            set { ViewState["Data"] = value; }

        }

    }

}

Download a sample solution.

kick it on DotNetKicks.com   Friday, April 27, 2007 8:59:45 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

I am guessing that like most other blogs, people come across my piece of cyber space through a search engine. Just validating this theory.

Also thinking that I will try to post more frequently now that I have a really unique name!

 

-Andy

kick it on DotNetKicks.com   Friday, April 27, 2007 1:07:46 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [2]  | 
 Monday, February 05, 2007
http://www.netgear.com/Products/CommunicationsVoIP/Skype/SPH200D.aspx

I bought a Netgear / Skype phone and just love it. The real test will be if Jennifer is willing to use it over the long term. She tried it a couple of times over the weekend and I am guessing that it will all work out. $15 for the Skype plan and $150 or so for the phone.

I looked at a few of the Linksys phones but it just seemed silly to me that I needed to be logged on to my computer and running Skype to use the phone. That requirement was only slightly better than just using my headset and microphone. The Linksys 802.11 phone was an option but I didn't want a cell phone sized phone. That would have certainly caused it to fail the Jennifer test.

I also like that the Netgear phone uses standard AAA NiMh batteries. The sounds quality seems good. No noticlable echo or delay, only a bit of background static.

-A

kick it on DotNetKicks.com   Monday, February 05, 2007 1:35:15 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, January 25, 2007
int? i;
object o;

// this is ok:
if (i.HasValue)
    o = i;
else
    o = DBNull.Value;

// This fails to compile. Error 1 Type of conditional expression cannot be determined
// because there is no implicit conversion between 'int?' and 'System.DBNull'
o = i.HasValue ? i : DBNull.Value;

// these also fail for the same reason
o = i == null ? DBNull.Value : i;
o = i.HasValue ? i : "ABC";

// but these works:
o = i.HasValue ? (object)i : DBNull.Value;
o = i.HasValue ? (object)i : (object)DBNull.Value;
o = i.HasValue ? i : (object)DBNull.Value;
kick it on DotNetKicks.com   Thursday, January 25, 2007 11:01:10 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, January 22, 2007
I am getting very excited about LINQ! I love diving into new technologies and feel that LINQ is going to be a big one for .NET and a big one for me.

For a while, I thought that AJAX would play a big role in my bag of tricks but I never made the leap. This doesn't mean that AJAX won't be used in my applications but I just don't see myself becoming a strong resource on AJAX.

As for LINQ, I exchanged a comment or two with Scott Guthrie and while I am reading a lot into it, it looks like Orcas will RTM this year and I am guessing that we will see some stable betas soon and go lives mid year. I am currently playing around with the Jan 07 CTP.

-A

kick it on DotNetKicks.com   Monday, January 22, 2007 8:57:54 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |