Just started learning Telerik APIs. Using C# / Linq. Reading up on MasterTableView and trying to hook up a simple grid which lists row data from an Orders table, including one column that lists the Name (a GridDropDownColumn) from a Customers table. So far no name is being displayed.
Where do I set datasource for the Customers table - how do I hook this up?
Thanks.
====
CREATE TABLE Customers
(
ID int NOT NULL IDENTITY(1,1) PRIMARY KEY,
Name varchar(128) NOT NULL
)
CREATE TABLE Orders
(
ID int NOT NULL IDENTITY(1,1) PRIMARY KEY,
Description varchar(32) NOT NULL,
CustomerID int NOT NULL FOREIGN KEY REFERENCES Customers(ID)
)
<telerik:RadGrid runat="server" ID="RadGrid_Order" AutoGenerateColumns="false" AllowPaging="true"
OnNeedDataSource="RadGrid_NeedDataSource" OnUpdateCommand="RadGrid_UpdateCommand"
OnItemCreated="RadGrid_ItemCreated" OnDeleteCommand="RadGrid_DeleteCommand"
OnInsertCommand="RadGrid_InsertCommand" OnItemDataBound="RadGrid_ItemDataBound">
<MasterTableView DataKeyNames="ID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="InPlace">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" />
<telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="true" ForceExtractValue="Always" ConvertEmptyStringToNull="true" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Description" />
<telerik:GridDropDownColumn UniqueName="RadCombo_Customer" HeaderText="Name" DropDownControlType="RadComboBox"
DataField="CustomerID" ListDataMember="Customers" ListValueField="ID" ListTextField="Name" />
<telerik:GridButtonColumn ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
</Columns>
<EditFormSettings>
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
RadGrid_Order.DataSource = OrdersTable.DataSource(); // query returns SELECT * FROM Orders;
}
Where do I set datasource for the Customers table - how do I hook this up?
Thanks.
====
CREATE TABLE Customers
(
ID int NOT NULL IDENTITY(1,1) PRIMARY KEY,
Name varchar(128) NOT NULL
)
CREATE TABLE Orders
(
ID int NOT NULL IDENTITY(1,1) PRIMARY KEY,
Description varchar(32) NOT NULL,
CustomerID int NOT NULL FOREIGN KEY REFERENCES Customers(ID)
)
<telerik:RadGrid runat="server" ID="RadGrid_Order" AutoGenerateColumns="false" AllowPaging="true"
OnNeedDataSource="RadGrid_NeedDataSource" OnUpdateCommand="RadGrid_UpdateCommand"
OnItemCreated="RadGrid_ItemCreated" OnDeleteCommand="RadGrid_DeleteCommand"
OnInsertCommand="RadGrid_InsertCommand" OnItemDataBound="RadGrid_ItemDataBound">
<MasterTableView DataKeyNames="ID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="InPlace">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" />
<telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="true" ForceExtractValue="Always" ConvertEmptyStringToNull="true" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Description" />
<telerik:GridDropDownColumn UniqueName="RadCombo_Customer" HeaderText="Name" DropDownControlType="RadComboBox"
DataField="CustomerID" ListDataMember="Customers" ListValueField="ID" ListTextField="Name" />
<telerik:GridButtonColumn ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
</Columns>
<EditFormSettings>
<EditColumn ButtonType="ImageButton" />
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
protected void RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
RadGrid_Order.DataSource = OrdersTable.DataSource(); // query returns SELECT * FROM Orders;
}