Open VisualWebPart1UserControl.ascx.cs
file and replace the code with the following.
using
System;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
Microsoft.SharePoint.Linq;
using
System.Linq;
using
System.IO;
using
System.Collections.Generic;
namespace
LinqToSQLWebpart.VisualWebPart1
{
public partial
class
VisualWebPart1UserControl : UserControl
{
protected
void Page_Load(object sender,
EventArgs e)
{
MyEntityClassDataContext
myEntitiesDataContext = new
MyEntityClassDataContext("http://servername:2010/sites/test/");
//Querying the list
var listItem =
from items in
myEntitiesDataContext.A
select items;
//Binding the result to the grid view
spGridView.DataSource = listItem;
spGridView.DataBind();
}
}
}