Pages

Oct 26, 2012

How to pass Eval value to javascript function from GridView ItemTemplate

Passing the Eval value to a javascript method is bit tricky.

You cannot pass directly as shown below.

<asp:LinkButton id='lnk' runat='server' OnClientClick='<%#Eval("columnname",
"javascript:testfun({0});")%>' />

Instead , the below way should work

<asp:LinkButton id='lnk' runat='server' OnClientClick='<%#Eval("columnname",
"javascript:testfun({0});")%>' />

Oct 9, 2012

How to alter all columns of a table in SQL SERVER

To alter all columns of a table :
 
DECLARE @SQL VARCHAR(MAX)
SET @SQL = (
SELECT '
ALTER TABLE dbo.yourtablename ALTER COLUMN [' + c.name + '] NVARCHAR(MAX) NULL;
'
FROM sys.columns c WHERE OBJECT_NAME(object_id) = 'yourtablename'
FOR XML PATH(''), TYPE
).value('text()[1]', 'VARCHAR(MAX)')
 
--PRINT @SQL
 
EXEC(@SQL)