I have a problem and I dont know how to resolve it.
I have a grid, in the grid I have some columns. When the page loads I want to appear the records of the grid but also the template to add new records, also has the link to add a new record, to edit and to remove (this two in each row of the records).
The template doesnt have all the fields on my table. But when I load the page I need to bind combos on my template and then save those values.
Here is my grid aspx:
<
<telerik:RadGrid ID="RadGridArticles" runat="server" AutoGenerateColumns="false" GridLines="None" OnNeedDataSource="RadGridArticles_NeedDataSource" OnInsertCommand="RadGridArticles_InsertCommand" OnDeleteCommand="RadGridArticles_DeleteCommand" OnUpdateCommand="RadGridArticles_UpdateCommand">
<MasterTableView DataKeyNames="Id" InsertItemDisplay="top" CommandItemDisplay="Top">
<CommandItemSettings AddNewRecordText="Add new record" ShowRefreshButton="false" />
<Columns>
<telerik:GridBoundColumn HeaderText="Article Name" DataField="Name"></telerik:GridBoundColumn>
<telerik:GridNumericColumn HeaderText="Amount" DataField="ArticleAmount"></telerik:GridNumericColumn>
<telerik:GridNumericColumn HeaderText="Price" DataField="ArticlePrice" NumericType="Currency" DecimalDigits="2"></telerik:GridNumericColumn>
<telerik:GridBoundColumn HeaderText="Category" DataField="CategoryName"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Category THF">
<ItemTemplate>
<%# Eval("CategoryName")%> <%# Eval("THFDescription")%>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridButtonColumn ButtonType="PushButton" Text="Add" CommandName="Edit"></telerik:GridButtonColumn>
<telerik:GridButtonColumn ButtonType="PushButton" Text="Remove" CommandName="Delete"></telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<FormTemplate>
<div style="padding: 10px;">
<div>
<asp:Label ID="LabelArticle" runat="server" Text="Article"></asp:Label>
<telerik:RadTextBox ID="RadTextBoxArticle" runat="server" AppendDataBoundItems="true" DataTextField="Name" DataValueField="Id" ></telerik:RadTextBox>
</div>
<div>
<asp:Label ID="LabelArticleAmount" runat="server" Text="Amount" ></asp:Label>
<telerik:RadNumericTextBox ID="RadNumericTextBoxAmount" runat="server" AppendDataBoundItems="true" Type="Currency"></telerik:RadNumericTextBox>
</div>
<div>
<asp:Label ID="LabelCateg" runat="server" Text="Category" ></asp:Label>
<telerik:RadComboBox ID="RadComboBoxCateg" runat="server" Type="Number" DataValueField="IdCategory" DataTextField="CategoryName" ></telerik:RadComboBox>
</div>
<div>
<asp:Label ID="LabelTHF" runat="server" Text="THF" ></asp:Label>
<telerik:RadComboBox ID="RadComboBoxTHF" runat="server" Type="Currency" DataValueField="IdTHF" DataTextField="THFDescription" AppendDataBoundItems="true"></telerik:RadComboBox>
</div>
<div>
<asp:Button ID="ButtonUpdate" runat="server" CommandName="Update" ></asp:Button>
<asp:Button ID="ButtonInsert" runat="server" CommandName="PerformInsert" ></asp:Button>
</div>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
I tried to load the combo like this but nothing. Hopw someone can help me!
Thanks telerik team!!!
protected void RadGridExpensesLines_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
{
GridEditFormItem editform = (GridEditFormItem)e.Item;
RadComboBox ComboBox = (RadComboBox)editform.FindControl("RadComboBoxTHF");
Combobox.datasource=MYDATASOURCE;
}
}
