I want to be able to intercept the insert action for a RadGrid and display a window allowing the user to select criteria which will then be carried over into the true editing control to pre-populate some of the data. I know that I can pre-populate controls in the ItemCommand event with hard-coded values by checking for InitInsertCommandName and locating the controls to populate.
Can I at this point open a radwindow containing the below and page. This window will allow the user to select from the 2 dropdowns & the textbox and on clicking the 'Select' button populate the grid with matching data from a database. On double clicking a row of data, that data will be sent back to the ItemCommand to populate the edit control.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ItemSelection.aspx.cs" Inherits="MaxOrdersTab.Dialogs.ItemSelection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"gridLoadingPanel"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"gridLoadingPanel"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
div
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
AssociatedControlID
=
"ddlProviders"
>Product Provider: </
asp:Label
>
<
telerik:RadDropDownList
ID
=
"ddlProviders"
runat
=
"server"
Width
=
"200px"
CssClass
=
"DropDown_Providers"
>
</
telerik:RadDropDownList
>
<
asp:Label
ID
=
"Label2"
runat
=
"server"
AssociatedControlID
=
"ddlGroups"
> Product Group: </
asp:Label
>
<
telerik:RadDropDownList
ID
=
"ddlGroups"
runat
=
"server"
>
</
telerik:RadDropDownList
>
<
asp:Label
ID
=
"Label3"
runat
=
"server"
AssociatedControlID
=
"tbxDescription"
> Product Description: </
asp:Label
>
<
telerik:RadTextBox
ID
=
"tbxDescription"
runat
=
"server"
>
</
telerik:RadTextBox
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Select"
onclick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
br
/>
<
br
/>
<
telerik:RadAjaxLoadingPanel
ID
=
"gridLoadingPanel"
runat
=
"server"
Skin
=
"Default"
Width
=
"100%"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnItemCreated
=
"RadGrid1_ItemCreated"
AllowPaging
=
"True"
Width
=
"99%"
AutoGenerateColumns
=
"False"
IsExporting
=
"False"
PageSize
=
"15"
ShowHeader
=
"False"
GroupPanelPosition
=
"Top"
>
<
MasterTableView
ClientDataKeyNames
=
"SelectionID"
Width
=
"100%"
CommandItemDisplay
=
"None"
PageSize
=
"5"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Product_Provider"
HeaderText
=
"Product Provider"
ReadOnly
=
"true"
SortExpression
=
"Product_Provider"
UniqueName
=
"Product_Provider"
AllowSorting
=
"False"
Exportable
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
FilterControlAltText
=
"Filter Product_Provider column"
>
<
HeaderStyle
Font-Bold
=
"True"
/>
<
ItemStyle
Width
=
"20%"
Wrap
=
"False"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Product_Group"
HeaderText
=
"Product Group"
ReadOnly
=
"true"
SortExpression
=
"Product_Group"
UniqueName
=
"Product_Group"
AllowFiltering
=
"False"
AllowSorting
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
FilterControlAltText
=
"Filter Product_Group column"
>
<
HeaderStyle
Font-Bold
=
"True"
/>
<
ItemStyle
Width
=
"20%"
Wrap
=
"False"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Product_Code"
HeaderText
=
"Product Code"
ReadOnly
=
"True"
SortExpression
=
"Product_Code"
UniqueName
=
"Product_Code"
AllowFiltering
=
"False"
AllowSorting
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
FilterControlAltText
=
"Filter Product_Code column"
>
<
HeaderStyle
Font-Bold
=
"True"
/>
<
ItemStyle
Width
=
"20%"
Wrap
=
"False"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Product_Description"
HeaderText
=
"Product Description"
ReadOnly
=
"true"
SortExpression
=
"Product_Description"
UniqueName
=
"Product_Description"
AllowFiltering
=
"False"
AllowSorting
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
>
<
HeaderStyle
Font-Bold
=
"True"
/>
<
ItemStyle
Width
=
"40%"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Unit_Sell"
HeaderText
=
"Unit Sell"
SortExpression
=
"Unit_Sell"
UniqueName
=
"Unit_Sell"
AllowFiltering
=
"False"
AllowSorting
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Unit_Cost"
HeaderText
=
"Unit Cost"
SortExpression
=
"Unit_Cost"
UniqueName
=
"Unit_Cost"
AllowFiltering
=
"False"
AllowSorting
=
"False"
Groupable
=
"False"
Reorderable
=
"False"
Resizable
=
"False"
ShowSortIcon
=
"False"
Visible
=
"False"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
MainTableCaption
=
"Line Item Selection"
/>
<
ExportSettings
>
<
Pdf
AllowPrinting
=
"False"
>
</
Pdf
>
<
Csv
EncloseDataWithQuotes
=
"False"
/>
</
ExportSettings
>
<
ValidationSettings
EnableModelValidation
=
"False"
EnableValidation
=
"False"
/>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
></
Selecting
>
<
ClientEvents
OnRowDblClick
=
"RadGrid1_RowDblClick"
></
ClientEvents
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
telerik:RadAjaxLoadingPanel
>
</
div
>
</
form
>
</
body
>
</
html
>
protected
void
RadGrid1_ItemCommand(
object
source, Telerik.Web.UI.GridCommandEventArgs e)
{
GridEditableItem insertedItem;
String MyUserControlId;
UserControl MyUserControl;
switch
(e.CommandName)
{
case
RadGrid.InitInsertCommandName:
e.Canceled =
true
;
// display the RadWindow here to request the data to pre-populate the edit control.
e.Item.OwnerTableView.InsertItem();
insertedItem = e.Item.OwnerTableView.GetInsertItem();
MyUserControlId = GridEditFormItem.EditFormUserControlID;
MyUserControl = insertedItem.FindControl(MyUserControlId)
as
UserControl;
RadNumericTextBox box;
box = MyUserControl.FindControl(
"ntbUnitCost"
)
as
RadNumericTextBox;
box.Value =
// Value1 returned from selection dialog
box = MyUserControl.FindControl(
"ntbUnitSell"
)
as
RadNumericTextBox;
box.Value =
// Value2 returned from selection dialog
box = MyUserControl.FindControl(
"ntbQty"
)
as
RadNumericTextBox;
box.Focus();
break
;
default
:
break
;
}
}