Archive for the ‘Uncategorized’ Category

Posted by admin at 10 August 2010

Category: Uncategorized

A fast way to get a list you can copy into a code file with all the fields in a table.

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = ‘tablename’

Posted by admin at 8 August 2010

Category: Uncategorized

Entity Framework (EF) does not support lazy loading. You must explicitly load the comments advising the EF what to include.

Using ctx as new MyDataContext()

lvComments.DataSource = ctx.Entity.Include(“SomethingToInclude”).First().Comments
lvComments.Databind()

End Using

Or

Using ctx as new MyDataContext()

Dim MyListOfSomething as List(of ListOfSomething) = ctx.ListOfSomething
MyListOfSomething.SomethingToLoad.Load()
lvComments.DataSource = MyListOfSomething.Comments
lvComments.DataBind()

End Using

Posted by admin at 19 July 2010

Category: Uncategorized

The problem: no .csproj file in websites

The solution: http://www.dotnetsizzler.com/post/Using-MS-Build-in-ASPNET-Website.aspx Add a proj file to the website, and set up the build to use it.  http://en.csharp-online.net/MSBuild:_By_Example%E2%80%94Dealing_with_MSBuild_Errors

Posted by admin at 12 July 2010

Category: Uncategorized

Here are a few ways to get the value of an asp textbox

  1. document.getElementById(‘<%=Test.ClientID%>’).value
  2. <%=txtMyTextBox.ClientID%>
  3. Response.Redirect(“Form2.aspx?name=” + txtName.Text + “&num=” + txtStNum.Text );

Posted by admin at 25 May 2010

Category: Uncategorized

String.Join(“,”,Array.ConvertAll(list.ToArray(),element => element.ToString()));

Posted by admin at 31 March 2010

Category: Uncategorized

For entity framework, you should use ObjectContext.AddObject() instead of Linq to SQL DataContext.TableName.Add()

Posted by admin at 24 February 2010

Category: Uncategorized

http://msdn.microsoft.com/en-us/library/ms229002.aspx

Posted by admin at 24 February 2010

Category: Uncategorized

var selectCustomer = from c in dbContext.Customer.Include(“Invoice.Product”)
where c.Id == id
select c

Posted by admin at 11 February 2010

Category: Uncategorized

http://www.microsoft.com/learning/en/us/certification/mcts.aspx#tab3

Posted by admin at 10 February 2010

Category: Uncategorized

Use PRG pattern for data modification

“PRG stands for Post-Redirect-Get to avoid the classic browser warning when refreshing a page after post.  Whenever you make a POST request, once the request complets do a redirect so that a GET request is fired.  In this way when the user refresh the page, the last GET request will be executed rather than the POST thereby avoiding unnecessary usability issue.”