How can i stay in insert mode after i created a new record?
i have seen a lot of solutions to close the insert window but nothing to keep it open.
my code aspx:
aspx.cs:
i have seen a lot of solutions to close the insert window but nothing to keep it open.
my code aspx:
<telerik:RadGrid EnableViewState="true" EnableEmbeddedSkins="False" Skin="ABCustom" OnItemDataBound="RadGrid2_ItemCommand" |
runat="server" ID="productrelations" OnNeedDataSource="datarelations" OnInsertCommand="RadGrid2_InsertCommand" |
AutoGenerateColumns="false" AllowSorting="true" > |
<MasterTableView NoMasterRecordsText="Er zijn momenteel geen vergelijkbare producten geselecteerd" |
CommandItemDisplay="Top" DataKeyNames="ProductBaseId"> |
<Columns> |
<telerik:GridBoundColumn UniqueName="ProductBaseId" HeaderText="ProductBaseId" DataField="ProductBaseId" |
SortExpression="ProductBaseId" Visible="false" ReadOnly="true" /> |
<telerik:GridTemplateColumn UniqueName="RelatedProducts" AllowFiltering="false" HeaderText="Vergelijkbare producten" |
SortExpression="RelatedProductBaseId"> |
<ItemTemplate> |
<%# Eval("RelatedProductBase.Name")%> |
</ItemTemplate> |
<EditItemTemplate> |
<asp:DropDownList runat="server" ID="relatedCategory" OnSelectedIndexChanged="fillproduct" |
AutoPostBack="true" /> |
<asp:DropDownList runat="server" ID="relatedProduct" /> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn AllowFiltering="false" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" HeaderText="Acties" UniqueName="Actions"> |
<ItemTemplate> |
<asp:ImageButton runat="server" ID="deleterelation" ImageUrl="~/Images/delete.png" |
OnCommand="relation_OnClick" CommandArgument='<%# Eval("RelatedProductBaseId") %>' ToolTip="Delete" |
OnClientClick="return confirm('Weet u zeker dat u de relatie met dit product wilt verwijderen?');" |
CausesValidation="false" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
<EditFormSettings EditColumn-ButtonType="ImageButton" EditColumn-InsertImageUrl="~/Images/SaveBtn.gif" |
EditColumn-UpdateImageUrl="~/Images/SaveBtn.gif" EditColumn-CancelImageUrl="~/Images/CancelBtn.gif"> |
</EditFormSettings> |
<CommandItemSettings AddNewRecordText="Vergelijkbare producten toevoegen" AddNewRecordImageUrl="~/Images/AddRecord.gif" |
RefreshText="Verversen" RefreshImageUrl="~/Images/Refresh.gif" /> |
</MasterTableView> |
</telerik:RadGrid> |
aspx.cs:
protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if ((e.Item is GridEditFormItem) && e.Item.IsInEditMode) |
{ |
PrefetchPath prefetch = new PrefetchPath(EntityType.CategoryBaseEntity); |
prefetch.Add(CategoryBaseEntity.PrefetchPathSubCategoryBase); |
GridEditFormItem categorydopdown = (GridEditFormItem)e.Item; |
DropDownList dropdownlistcategory = (DropDownList)categorydopdown.FindControl("relatedCategory"); |
CategoryBaseCollection theCategoryColl = new CategoryBaseCollection(); |
theCategoryColl.GetMulti(CategoryBaseFields.IsActive == true, prefetch); |
dropdownlistcategory.Items.Add(new ListItem("- Selecteer een Category -", "0")); |
foreach (CategoryBaseEntity category in theCategoryColl) |
{ |
dropdownlistcategory.Items.Add(new ListItem(category.Name, category.Id.ToString())); |
foreach (SubCategoryBaseEntity subCategory in category.SubCategoryBase) |
{ |
dropdownlistcategory.Items.Add(new ListItem(".." + subCategory.Name, ".." + subCategory.Id.ToString())); |
} |
} |
} |
} |
protected void RadGrid2_InsertCommand(object source, GridCommandEventArgs e) |
{ |
GridEditFormInsertItem insertitems = (GridEditFormInsertItem)e.Item; |
ProductRelationBaseEntity newproduct = new ProductRelationBaseEntity(); |
DropDownList deliverytime = (DropDownList)insertitems.FindControl("relatedProduct"); |
newproduct.ProductBaseId = Url.QueryStringParser.GetInt("ProductId"); |
newproduct.RelatedProductBaseId = int.Parse(deliverytime.SelectedValue); |
newproduct.Save(); |
productrelations.DataBind(); |
} |
protected void fillproduct(object sender, EventArgs e) |
{ |
DropDownList dropdownlistcategory = (DropDownList)sender; |
DropDownList dropdownlistprodudct = (DropDownList)dropdownlistcategory.Parent.FindControl("relatedProduct"); |
ProductBaseCollection productcollection = new ProductBaseCollection(); |
if (dropdownlistcategory.SelectedItem.Text.Substring(0, 2) == "..") |
{ |
productcollection.GetMulti(ProductBaseFields.SubCategoryBaseId == int.Parse(dropdownlistcategory.SelectedValue.Substring(2, dropdownlistcategory.SelectedValue.Length - 2)) & ProductBaseFields.IsDeleted == false); |
} |
else |
{ |
productcollection.GetMulti(ProductBaseFields.CategoryId == int.Parse(dropdownlistcategory.SelectedValue) & ProductBaseFields.IsDeleted == false); |
} |
dropdownlistprodudct.Items.Clear(); |
dropdownlistprodudct.Items.Add(new ListItem("- Selecteer een product -", "0")); |
foreach (ProductBaseEntity product in productcollection) |
{ |
ProductRelationBaseEntity productrelation = new ProductRelationBaseEntity(Url.QueryStringParser.GetInt("ProductId"), product.Id); |
if (productrelation.IsNew == true && Url.QueryStringParser.GetInt("ProductId") != product.Id) |
dropdownlistprodudct.Items.Add(new ListItem(product.Name, product.Id.ToString())); |
} |
} |
protected void datarelations(object source, GridNeedDataSourceEventArgs e) |
{ |
ProductRelationBaseCollection product = new ProductRelationBaseCollection(); |
product.GetMulti(ProductRelationBaseFields.ProductBaseId == Url.QueryStringParser.GetInt("ProductId")); |
productrelations.DataSource = product; |
} |