19 June 2015

Pass the ID in a gridView ButtonField

Nel file .aspx ricordarsi di impostare il DataKeyNames!!


    
        
    


Il trucco è che e.CommandArgument contiene l'indice della riga che ha scatenato l'evento:
Protected Sub gridOrdini_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gridOrdini.RowCommand

    Dim selectedIndex As Integer = CType(e.CommandArgument, Integer)

    Dim wID As String = Me.gridOrdini.DataKeys(selectedIndex).Value.ToString()

    Me.Response.Write(wID)

End Sub

Via

Visual Studio 2010: how to force ASP.NET website to use x86 instead of “Any CPU”?

Bisogna aggiungere compilerOptions="/platform:x86" al nodo <compiler> del web.config (sia per C# che per VB):



  

    
    
  

  

    
    
    

  


Via

MSDN page: <compiler> Element

MSDN: /platform (C# Compiler Options)

17 June 2015

Type or namespace could not be found from App_code folder

Se non si vedono le classi create nella App_Code, chiedersi che tipo di progetto si è creato in Visual Studio: "New Project" ("sbagliato") o "New Website"?


Spiegazione:


Perhaps the problem will be solved by changing the Build Action Property of the *.cs source file to Compile from Content. From the Solution Explorer right click on the source file and choose Property.
Note that the App_Code folder is intended for use in Web Site Projects.
Note that for a Web Application Project or MVC project, adding an App_Code folder to your project and putting *.cs files in it will cause problems. I ignorantly added an App_Code folder to my MVC project from the Solution Explorer. VS defaulted the name space to MyProjectName.App_Code. In this case Visual Studio 2012 defaulted the Build Action to Content, even though the type was .cs code. After I changed Build Action Property of the *.cs source file to Compile from Content the namespace was resolved in other folder locations of the project. However because of problems, I had to change the name of folder--see below.
Important
In the MVC or Web Application project, the App_Code folder is trouble because it has Web Site Project type semantics. This folder is compiled when published (deployed) to the server. By changing Build Action from Content to Compile, you resolve the namespace issue on your development environment by forcing immediate compilation, but you get trouble when the second compilation results in objects defined twice errors on deployment. Put the code files in a folder with a different name. If you converted a Web Site to a Web Application, see the guidelines on the Net for this--not in the scope of this question. To read more about App_Code folder in the different project types see this blog

http://stackoverflow.com/questions/9178985/type-or-namespace-could-not-be-found-from-app-code-folder




http://vishaljoshi.blogspot.it/2009/07/appcode-folder-doesnt-work-with-web.html

LogMeIn Pro and Windows Server 2012 r2

Sintomo:
dopo il login, lo schermo resta nero:

Soluzione:
nella keboard toolbar, cambiare da "legacy logmein mapping" a "use client layout", disconnettersi e riconettersi.

(Provato in SAP)

Via.

12 June 2015

Properties vs Fields – Why Does it Matter?

On the surface there doesn’t seem to be a big difference between this:
Public Property Name() As String
And this:
Public Name() As String

Clearly both will expose an object’s state to the outside world, and can be read/modified using the exact same syntax. Which then begs the question, why would I ever use a property if I have no special logic in the Getter/Setter?


Via

getting list of tables and fields in each in a database / sys_IsNullTable_sp

SELECT 
  C.TABLE_NAME, C.COLUMN_NAME, C.DATA_TYPE, 
  CASE 
   WHEN C.CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN 'STRINGA'
   WHEN C.NUMERIC_PRECISION IS NOT NULL THEN 'NUMERO'
   WHEN C.DATETIME_PRECISION IS NOT NULL THEN 'DATA'
  END
FROM INFORMATION_SCHEMA.COLUMNS C
WHERE C.IS_NULLABLE = 'YES'
 AND C.DATA_TYPE NOT LIKE '%bit%'
 AND C.DATA_TYPE NOT LIKE '%timestamp%'
 --AND C.TABLE_NAME = 'dev_web_Ordini_tb'

ORDER BY C.DATA_TYPE




ALTER PROCEDURE sys_IsNullTable_sp
   @tabName AS nvarchar(500)
 , @testMode AS bit = 0
AS
BEGIN
 -- 2015-06-12 - CREATE PROCEDURE
 
 /**************************************************************************
  IMPOSTA I CAMPI NULLI CON VALORI DI DEFAULT:
  '' SE E' UN TESTO
  0  SE E' UN NUMERO 
 **************************************************************************/
 
 -- per ora non gestisco i tipi date (che default uso??)
 -- nel caso, basta REMmare e SREMmare il codice!
 
 SET NOCOUNT ON
 
 DECLARE @sq as nvarchar(MAX) = ''

 SET @tabName = QUOTENAME(@tabName)

 DECLARE #cur CURSOR FOR
 --SELECT N'UPDATE ' + @tabName + ' SET ' + c.name + ' = ' 
 --   + CASE WHEN t.name LIKE '%char' THEN ''''''
 --     --WHEN t.name LIKE '%date%' THEN 'x'
 --     ELSE '0'
 --    END +  
 --   ' WHERE ' + c.name + ' IS NULL'
 --FROM sys.columns c
 --  INNER JOIN sys.types t
 --   ON c.user_type_id = t.user_type_id
 --WHERE OBJECT_ID = OBJECT_ID(@tabName)
 -- AND c.is_nullable = 1
 -- AND t.name NOT LIKE '%date%'

 SELECT N'UPDATE ' + @tabName + ' SET ' + c.COLUMN_NAME + ' = ' 
     + CASE 
       WHEN C.CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN '''''' -- 'STRINGA'
       WHEN C.NUMERIC_PRECISION IS NOT NULL THEN '0' -- 'NUMERO'
       --WHEN C.DATETIME_PRECISION IS NOT NULL THEN 'DATA'
      END

     + ' WHERE ' + c.COLUMN_NAME + ' IS NULL'
 FROM INFORMATION_SCHEMA.COLUMNS C
 WHERE C.IS_NULLABLE = 'YES'
  AND C.DATA_TYPE NOT LIKE '%bit%'
  AND C.DATA_TYPE NOT LIKE '%timestamp%'
  AND C.DATETIME_PRECISION IS NULL -- esclude le date
  AND QUOTENAME(C.TABLE_NAME) = @tabName



 OPEN #cur
 FETCH NEXT FROM #cur INTO @sq

 WHILE @@FETCH_STATUS = 0
  BEGIN
   IF @testMode = 0
    EXEC sp_executesql @sq
   ELSE
    PRINT @sq
    
   FETCH NEXT FROM #cur INTO @sq
  END

 CLOSE #cur
 DEALLOCATE #cur

END
GO


http://stackoverflow.com/questions/420741/getting-list-of-tables-and-fields-in-each-in-a-database