Hi
I am using a RadGrid, and trying to use a custom User Control edit form. I have just created a test page, where I am binding the RadGrid to a List<T> of a custom Business Object.
When I click on the EditCommandColumn, I notice that the e.Item.IsInEditMode is always false, and I am unable to retrieve a reference to the UserControl using the documented method of:
userControl is always null :(
I am using a <telerik:AjaxScriptManager> to perform all operations using AJAX if this helps shed any light on the matter
Cheers
Simon
ASPX Page is as follows:
I am using a RadGrid, and trying to use a custom User Control edit form. I have just created a test page, where I am binding the RadGrid to a List<T> of a custom Business Object.
When I click on the EditCommandColumn, I notice that the e.Item.IsInEditMode is always false, and I am unable to retrieve a reference to the UserControl using the documented method of:
GridEditableItem editedItem = e.Item as GridEditableItem;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
userControl is always null :(
I am using a <telerik:AjaxScriptManager> to perform all operations using AJAX if this helps shed any light on the matter
Cheers
Simon
ASPX Page is as follows:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" Skin="WebBlue" GridLines="None" AllowPaging="True" AllowSorting="True" Width="97%" AutoGenerateColumns="False" ShowStatusBar="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound">
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" DataKeyNames="Id">
<Columns>
<telerik:GridBoundColumn DataField="ProductCode" HeaderText="Prod Code" />
<telerik:GridBoundColumn DataField="Description" HeaderText="Desc" />
<telerik:GridBoundColumn DataField="Quantity" HeaderText="Qty" />
<telerik:GridBoundColumn DataField="DeliveryDate" HeaderText="Del Date" DataFormatString="{0:dd/MM/yy}" />
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" />
</Columns>
<EditFormSettings UserControlName="/UserControls/ProductEditor.ascx" EditFormType="WebUserControl">
<EditColumn UniqueName="EditCommandColumn1"></EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
CS File is as follows:
protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
if ( userControl == null)
throw new Exception("Unable to find UserControl");
}
private List<Objects.Product> ProductList
{
get
{
Object oProductList = Session["Products"];
if (oProductList != null)
return oProductList as List<Objects.Product>;
List<Objects.Product> productList = new List<Product>();
Product prod1 = new Product
{
Id = 1,
Description = "Product One (Event)",
ProductCode = "1001",
ProductType = Enums.ProductType.Event,
DeliveryDate = DateTime.Now.AddMonths(1)
};
Product prod2 = new Product
{
Id = 2,
Description = "Product Two (Material)",
ProductCode = "1002",
ProductType = Enums.ProductType.Material,
DeliveryDate = DateTime.Now.AddMonths(2)
};
productList.Add(prod1);
productList.Add(prod2);
Session["Products"] = productList;
return productList;
}
}