Sunday, May 24, 2015

Visual Studio 2012, 2013, 2015 and ASP.NET Web Configuration Tool

Run this command in console(cmd)
"C:\Program Files\IIS Express\iisexpress.exe" /path:c:\windows\Microsoft.NET\Framework\v4.0.30319\ASP.NETWebAdminFiles /vpath:"/asp.netwebadminfiles" /port:8089 /clr:4.0 /ntlm
Than open your browser and open this url http://localhost:8089/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=[Exact_Project_Path]\&applicationUrl=/ 
Also make sure you have this connection string in your web.config file
<connectionStrings>
    <clear/>
    <add name="LocalSQLServer" connectionString="......." providerName="System.Data.SqlClient"/>
  </connectionStrings>
<clear> is important

Tuesday, May 19, 2015

LINQ: SqlDateTime overflow. Must be between ...

WHEN a NULL value to passed to a non null datetime field using LINQ datasource. If the field is autogenerated make sure to mark as autogenerated in LINQ DBML designer else pass the value using a parameter

Thursday, May 14, 2015

Get all asp net listview items in array

var rows = [];
$('#<%: lvStudents.ClientID %>_itemPlaceholderContainer tr:gt(1)').each(function (i, v) {
    var row = $(this);
    rows.push(row);
});
if InsertItemPosition="LastItem"
gt(1)
else if InsertItemPosition="FirstItem" 
gt(2)

Skip first N elements in JQuery

jQuery has a gt selector. (Greater than).
$('#test > div:gt(1)');
Or you can use the slice function
$('#test > div').slice(2);

Wednesday, May 13, 2015

How to update rows randomly

update dbo.Table 
set Field = Value 
where Id in ( select top 50 percent id from dbo.Table order by NEWID() )