[Default]
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" >
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90"/>
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="90" EditType="Dropdown" />
. . . . . . .
</Columns>
</ej:Grid>
[Default.aspx]
List<Customer> customers = new List<Customer>();
protected void Page_Load(object sender, EventArgs e)
{
customers.Add(new Customer() { text = "Andreas", value = "Andreas" });
customers.Add(new Customer() { text = "Frank" , value = "Frank" });
customers.Add(new Customer() { text = "Willi" , value = "Willi" });
customers.Add(new Customer() { text = "Horst" , value = "Horst" });
customers.Add(new Customer() { text = "Manfred", value = "Manfred" });
BindDataSource();
}
private void BindDataSource()
{
. . . . . . .
this.OrdersGrid.DataSource = order;
var index = this.OrdersGrid.Columns.FindIndex(col => col.Field == "CustomerID");
this.OrdersGrid.Columns.ElementAt(index).DataSource = customers;
this.OrdersGrid.DataBind();
}
[Serializable]
public class Customer
{
public Customer()
{
}
public Customer(string text, string value)
{
this.text = text;
this.value = value;
}
public string text { get; set; }
public string value { get; set; }
}
} |