Great article: DataContext vs ItemsSource (in Binding case)
The difference is that when using DataContext, it means that you bind the owner object of DataContext with the reference, which is DataContext pointed to. So, it some cases such as DataGrid or ListBox. We use ItemSource instead when we're talking about data in each row, not the DataGrid itself. On the other hand, we use DataContext to set binding from source ojbect to DataGrid directly.
Pages
Profile
|
|
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time.
Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more... |
Saturday, July 30, 2011
Thursday, July 28, 2011
How to pass Dynamic Anonymous Object to ViewPage in Razor
Normally, you can't pass anonymous object as a model to ViewPage because it can only be accessed from within the assembly in which it’s declared. Since views get compiled separately, the dynamic binder complains that it can’t go over that assembly boundary. So, to solve this problem we have to create own ViewPage that use dynamic object as a Model, or create extension method to change its type to ExpandoObject.
Using ExpandoObject:
Then, you can pass anonymous object through Model, and use it as dynamic object.
References: http://stackoverflow.com/questions/5120317/dynamic-anonymous-type-in-razor-causes-runtimebinderexception, http://blogs.msdn.com/b/davidebb/archive/2009/12/18/passing-anonymous-objects-to-mvc-views-and-accessing-them-using-dynamic.aspx
Using ExpandoObject:
public static ExpandoObject ToExpando(this object anonymousObject)
{
IDictionary anonymousDictionary =
HtmlHelper.AnonymousObjectToHtmlAttributes(anonymousObject);
IDictionary expando = new ExpandoObject();
foreach (var item in anonymousDictionary)
expando.Add(item);
return (ExpandoObject)expando;
}
Then, you can pass anonymous object through Model, and use it as dynamic object.
References: http://stackoverflow.com/questions/5120317/dynamic-anonymous-type-in-razor-causes-runtimebinderexception, http://blogs.msdn.com/b/davidebb/archive/2009/12/18/passing-anonymous-objects-to-mvc-views-and-accessing-them-using-dynamic.aspx
Labels:
ASP.NET,
MVC,
Programming
Wednesday, July 27, 2011
Comparison of NoSQL
Nowadays, there are many NoSQL tools or engines to use. Some people may not know which one should be used. Let's see the NoSQL comparison to know their strength and weakness here: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis. If you don't know what NoSQL is, take a look here: http://en.wikipedia.org/wiki/NoSQL.
Labels:
Database Technology,
NoSQL
Wednesday, June 29, 2011
Using Google App Engine as Proxy for Silverlight and Flash Cross-Domain Requests
Try this link, he explained important issues for doing it: http://gregdoesit.com/2010/12/using-google-app-engine-as-proxy-for-cross-domain-requests/.
Labels:
Internet Technology,
Programming,
Python,
Security,
Silverlight
Wednesday, June 22, 2011
Did you meant to say/did you mean to say
It must be "Did you mean to say" because meant is a past participle form of mean and did shows that this sentence is in the past.
Credit: http://www.englishforums.com/English/DidMeantMeanSay/ddkbn/post.htm
Credit: http://www.englishforums.com/English/DidMeantMeanSay/ddkbn/post.htm
Labels:
Language
Monday, June 20, 2011
Requiring HTTPS in ASP.NET MVC3
You can simply use RequireHttpsAttribute to your Action or Controller.
For Example:
More details at: http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx, http://salvoz.com/blog/2009/04/25/partial-ssl-and-authorization-with-asp-net-mvc-revisited/
For Example:
[RequireHttps]
public ActionResult SignIn()
{
return View();
}
More details at: http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx, http://salvoz.com/blog/2009/04/25/partial-ssl-and-authorization-with-asp-net-mvc-revisited/
Labels:
ASP.NET,
Internet Technology,
MVC,
Programming
Sunday, June 19, 2011
Lets vs let's
To let means to "allow".
Let him in. = Allow him to come in.
The word "let's" means "let us"
The first comes with the pronoun "us".
The second does not come with the pronoun "us".
She lets [allows] him to paint. = She allows him to paint.
So the rule is that when you mean let us, or allow us, or permits us, you use let's.
The following examples do not have the plural pronoun [us] contraction so no apostrophy is used.
She lets me paint. = She allows me to paint.
She lets them paint. = She allows them to paint.
She lets him or her paint. She allows him or her to paint.
Credit: http://www.englishforums.com/English/LetsVsLets/gnbh/post.htm from Radrook
Let him in. = Allow him to come in.
The word "let's" means "let us"
The first comes with the pronoun "us".
The second does not come with the pronoun "us".
She lets [allows] him to paint. = She allows him to paint.
So the rule is that when you mean let us, or allow us, or permits us, you use let's.
The following examples do not have the plural pronoun [us] contraction so no apostrophy is used.
She lets me paint. = She allows me to paint.
She lets them paint. = She allows them to paint.
She lets him or her paint. She allows him or her to paint.
Credit: http://www.englishforums.com/English/LetsVsLets/gnbh/post.htm from Radrook
Labels:
Language
Monday, June 13, 2011
The Purdue Online Writing Lab (OWL)
It may helpful for people who not use English as the first language. Check out this link: https://owl.english.purdue.edu/.
Labels:
Language
Saturday, June 11, 2011
Silverlight vs WPF
Check this link: http://stackoverflow.com/questions/2010452/silverlight-vs-wpf
Labels:
Internet Technology,
Programming,
Silverlight,
WPF
Subscribe to:
Posts (Atom)