Todd DeLand my personal blog

17Jun/100

7 Free, Open Source Tomes For Your Edification

A few really good articles here that would be good to read. Specifically the one on Blender and Asterisk I’d like to read someday :)

 

Original [ostatic]

30Jun/090

Specified Cast is Invalid – Telerik RadGrid asp:CheckBox

Great solution to the "specified cast is invalid" problem while binding an asp.net CheckBox control inside of an Telerik RadGrid FormTemplate.

ASP.NET Classic Controls - Grid Forum - asp:Checkbox in FormTemplate. "Specified Cast is Invalid" .

From Fabian Schulz:

I ran across the same problem and have created a simple solution, which is most easy to use:

Create a usercontrol with the following code:

myCheckbox.ascx:

myCheckbox.ascx.cs:
public partial class Controls_myCheckBox : System.Web.UI.UserControl
{

private bool m_checked = false;

public object Checked
{
get { return m_checked; }
set
{
if (value.GetType() == DBNull.Value.GetType())
m_checked = false;
else if (value == null)
m_checked = false;
else if (value.GetType() == typeof(bool))
m_checked = (bool)value;
else
m_checked = false;
}
}

protected void Page_Load(object sender, EventArgs e)
{
m_checked = CheckBox1.Checked;
}

protected void Page_PreRender()
{
CheckBox1.Checked = m_checked;
}
}

In your aspx page you need to register that control in the head:

And now - you can use it like a regular checkbox without the Null problem:

Hope this helps!

Fabian

12Feb/090

Defy All Challenges – Microsoft Visual Studio

Ok, so go to this VS2008 promo page, click the Machinima Videos ball in the center left and watch a few of the videos. They are pretty funny, I like the last 3 or 4 the best

Defy All Challenges - Microsoft Visual Studio.

Tagged as: , No Comments
21Oct/080

mssql search entire catalog

Found this great stored procedure at http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

--To search all columns of all tables in a database for the keyword "Computer"
EXEC SearchAllTables 'Computer'
GO

Here is the complete stored procedure code:

CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN

-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
-- Purpose: To search all columns of all tables for a given search string
-- Written by: Narayana Vyas Kondreddi
-- Site: http://vyaskn.tripod.com
-- Tested on: SQL Server 7.0 and SQL Server 2000
-- Date modified: 28th July 2002 22:50 GMT

CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET  @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM     INFORMATION_SCHEMA.TABLES
WHERE         TABLE_TYPE = 'BASE TABLE'
AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND    OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM     INFORMATION_SCHEMA.COLUMNS
WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
AND    TABLE_NAME    = PARSENAME(@TableName, 1)
AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND    QUOTENAME(COLUMN_NAME) > @ColumnName
)

IF @ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)
END
END
END

SELECT ColumnName, ColumnValue FROM #Results
END