Binding To LinqDataSource control
RadGrid Markup
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="LinqDataSource1">
</telerik:RadGrid>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" OnSelecting="LinqDataSource1_Selecting"></asp:LinqDataSource>
Code behind section (dummy data generated using an Enumerable)
protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
e.Result = Enumerable.Range(1, 100).Select(x => new Order()
{
OrderID = x,
OrderDate = DateTime.Now.Date.AddDays(x).AddHours(x).AddMinutes(x),
Freight = x * 0.1,
ShipName = "Name " + x,
ShipCountry = "Country " + x
});
}
public class Order
{
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public double Freight { get; set; }
public string ShipName { get; set; }
public string ShipCountry { get; set; }
}
Protected Sub LinqDataSource1_Selecting(sender As Object, e As LinqDataSourceSelectEventArgs)
e.Result = Enumerable.Range(1, 100).Select(Function(x) New Order() With {
.OrderID = x,
.OrderDate = DateTime.Now.Date.AddDays(x).AddHours(x).AddMinutes(x),
.Freight = x * 0.1,
.ShipName = "Name " & x,
.ShipCountry = "Country " & x
})
End Sub
Public Class Order
Public Property OrderID As Integer
Public Property OrderDate As DateTime
Public Property Freight As Double
Public Property ShipName As String
Public Property ShipCountry As String
End Class