Saturday, May 31, 2014

Linq Query displayed in a literal asp control.

I need to query the database and select a string to display in an literal asp control. The table contains its Id and the String. Two fields.


Here is the Linq query I have written, but when I load I return the following.



protected void Page_Load(object sender, EventArgs e)
{
LinqQuery();
}

protected void LinqQuery()
{
NewsItemsDataContext dc = new NewsItemsDataContext();
var n =
from a in dc.GetTable<NewsItem>()
select a;

litNewsItems.Text = n.ToString();
}

SELECT [t0].[NewsItemId], [t0].[NewsItem] AS [NewsItem1], [t0].[PublishedDate] FROM [dbo].[NewsItems] AS [t0]


How do I display NewsItem1 in the literal control ??


No comments:

Post a Comment