Tuesday, November 18, 2008

Check/Uncheck all items in a CheckBoxList using ASP.NET and JavaScript

Here's an easy way to check or uncheck all items in a CheckBoxList.
 
 
JavaScript
 
function CheckBoxListSelect(cbControl, state)
{
     var chkBoxList = document.getElementById(cbControl);
     var chkBoxCount = chkBoxList.getElementsByTagName("input");
 
     for(var i=0; i < chkBoxCount.length; i++)
     {
          chkBoxCount[i].checked = state;
     }
 
     return false;
}
 
ASP.Net CheckBoxList
 
<div>
     <a href="javascript:void(0)" onclick="javascript: CheckBoxListSelect('<%=chkStates.ClientID %>', true)">Select All</a> | <a href="javascript:void(0)" onclick="javascript: CheckBoxListSelect('<%=chkStates.ClientID %>', false)">Select None</a>
</div>
 
<div>
     <asp:CheckBoxList ID="chkStates" RepeatColumns="6" Width="100%" runat="server" />
</div>

Tuesday, November 11, 2008

SSIS loading Excel validation error

I ran into a situation today where I needed to have an Excel Source for an Excel file that would not always exist at the path specified in the ExcelFilePath property. This would cause the SSIS package to fail when the Excel file did not exist since the Data Flow Task could not validate the Excel file.
 
 
The simple fix was to right click the Data Flow Task and go to Properties and set the DelayValidation property to True.

Importing Excel data with SQL Server Integration Services SSIS with unicode and non-unicode data issues

"If you have used SSIS to import Excel data into SQL Server you may have run into the issue of having to convert data from Unicode to non-Unicode."
 
This article discusses some different options for handling Unicode to non-Unicode warning messages that are fairly common if you deal with importing data from one source to another, for example from Excel to SQL.
 
 
In my case today I ended up just having to add a Data Conversion transformation between my Excel Source and SQL Server Destination to convert my data-types accordingly.