I'm trying to manually insert a row into an SQL table through the RadGrid's insert row function. My problem is that the InsertCommand event will not fire. Here's some code:
Visual Basic code:
I can tell you the ItemCreated event DOES fire and runs successfully. I just don't understand why the InsertCommand event doesn't fire. If anybody can tell me what I'm missing, it would be appreciated.
Thanks,
Patrick
<
telerik:RadGrid
ID
=
"grdDesc"
runat
=
"server"
AutoGenerateColumns
=
"false"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
EditMode
=
"InPlace"
DataKeyNames
=
"Descrip"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
ShowHeader
=
"false"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"PushButton"
UniqueName
=
"Edit"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"Descrip"
UniqueName
=
"Descrip"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
UseStaticHeaders
=
"true"
AllowScroll
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
telerik:RadInputManager
runat
=
"server"
ID
=
"RadInputManager1"
Enabled
=
"true"
>
<
telerik:TextBoxSetting
BehaviorID
=
"TextBoxSetting1"
>
</
telerik:TextBoxSetting
>
</
telerik:RadInputManager
>
Visual Basic code:
Protected
Sub
Page_Load(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Load
...
Dim
ctxSql
As
LINQtoSQLDataContext =
New
LINQtoSQLDataContext()
If
chkDesc.Checked =
True
Then
grdDesc.Visible =
True
Dim
descrips = From c
In
ctxSql.COMBOBOXes Where c.fieldname =
"DESCRIP"
Select
New
With
{c.descrip}
grdDesc.DataSource = descrips
grdDesc.DataBind()
Else
grdDesc.Visible =
False
End
If
...
End
Sub
Protected
Sub
grdDesc_ItemCreated(
ByVal
sender
As
Object
,
ByVal
e
As
GridItemEventArgs)
Handles
grdDesc.ItemCreated
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
(e.Item.IsInEditMode)
Then
Dim
editableItem
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
textBox = (
DirectCast
(editableItem.EditManager.GetColumnEditor(
"Descrip"
), GridTextBoxColumnEditor)).TextBoxControl
textBox.ID =
"TextBox1"
Dim
inputSetting
As
InputSetting = RadInputManager1.GetSettingByBehaviorID(
"TextBoxSetting1"
)
inputSetting.TargetControls.Add(
New
TargetInput(textBox.UniqueID,
True
))
inputSetting.InitializeOnClient =
True
inputSetting.Validation.IsRequired =
True
End
If
End
Sub
Protected
Sub
grdDesc_InsertCommand(sender
As
Object
, e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
grdDesc.InsertCommand
Dim
ctxSql
As
LINQtoSQLDataContext =
New
LINQtoSQLDataContext()
Dim
custFileID = ctxSql.CUSTFILEs.Where(
Function
(c) c.CUSTNO = cboCustNew.SelectedValue).
Single
.CUSTFILE
Dim
newComboBox
As
COMBOBOX =
New
COMBOBOX()
newComboBox.custfile = custFileID
newComboBox.department = -1
newComboBox.fieldname =
"DESCRIP"
newComboBox.descrip =
""
ctxSql.COMBOBOXes.InsertOnSubmit(newComboBox)
End
Sub
I can tell you the ItemCreated event DOES fire and runs successfully. I just don't understand why the InsertCommand event doesn't fire. If anybody can tell me what I'm missing, it would be appreciated.
Thanks,
Patrick