I have a telerik radgrid that uses a WebUserControl for editing data. The Delete ItemCommand fires properly but the Insert ItemCommand does not. Also, the Update ItemCommand opens the WebUserControl but once it opens, the Cancel and Update commands do not fire from the control.
Here is my ItemCommand code. This was working correctly but today I must have introduced a bug that affected it.
<
telerik:RadGrid
ID
=
"rgvEdit"
runat
=
"server"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
allowpaging
=
"True"
PageSize
=
"75"
GridLines
=
"None"
style
=
"margin-top: 0px"
RegisterWithScriptManager
=
"False"
DataSourceID
=
"dsGetChargeForms"
>
<
MasterTableView
NoMasterRecordsText
=
"No locations found."
CommandItemDisplay
=
"Top"
PageSize
=
"75"
AllowPaging
=
"true"
AllowSorting
=
"false"
DataKeyNames
=
"id"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"true"
AddNewRecordText
=
"Add New"
ShowRefreshButton
=
"false"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Subcategory"
DataField
=
"subcategory"
UniqueName
=
"subcategory"
/>
<
telerik:GridBoundColumn
DataField
=
"bar_procedure_code"
HeaderText
=
"Proc Code"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"display_code"
HeaderText
=
"Display Code"
SortExpression
=
"display_code"
UniqueName
=
"display_code"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"description"
HeaderText
=
"Description"
SortExpression
=
"description"
UniqueName
=
"description"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"min"
HeaderText
=
"Min"
SortExpression
=
"min"
UniqueName
=
"min"
></
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"requires_modifier"
DataType
=
"System.Boolean"
HeaderText
=
"Modifer?"
SortExpression
=
"requires_modifier"
UniqueName
=
"requires_modifier"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"requires_epsdt"
DataType
=
"System.Boolean"
HeaderText
=
"EPSDT?"
SortExpression
=
"requires_epsdt"
UniqueName
=
"requires_epsdt"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"requires_contraceptive_mgmnt"
DataType
=
"System.Boolean"
HeaderText
=
"Cont. Mgmt?"
SortExpression
=
"requires_contraceptive_mgmnt"
UniqueName
=
"requires_contraceptive_mgmnt"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"no_md_charge"
DataType
=
"System.Boolean"
HeaderText
=
"No MD?"
HeaderTooltip
=
"No MD Charge"
UniqueName
=
"no_md_charge"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridButtonColumn
Text
=
"Delete"
CommandName
=
"Delete"
ButtonType
=
"ImageButton"
/>
</
Columns
>
<
EditFormSettings
UserControlName
=
"OutptMgmtEditChgFormDetail.ascx"
EditFormType
=
"WebUserControl"
EditColumn-UniqueName
=
"OutptMgmtEditChgFormDetailCommand1"
>
</
EditFormSettings
>
</
MasterTableView
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<%--Datasources--%>
<
asp:SqlDataSource
ID
=
"dsGetChargeForms"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:OutpatientChargesConnectionString %>" SelectCommand="pSDGenie_OutpatientCharges_Get_ChargeForms" SelectCommandType="StoredProcedure">
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"ddlEditClinic"
DefaultValue
=
""
Name
=
"Clinic"
PropertyName
=
"SelectedValue"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"ddlEditCategory"
DefaultValue
=
""
Name
=
"Category"
PropertyName
=
"SelectedValue"
Type
=
"String"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
Here is my ItemCommand code. This was working correctly but today I must have introduced a bug that affected it.
Private
Sub
rgvEdit_ItemCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Handles
rgvEdit.ItemCommand
Select
Case
e.CommandName
Case
"PerformInsert"
Dim
MyUserControl
As
UserControl =
CType
(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
If
MyUserControl IsNot
Nothing
Then
'Insert
Dim
chgId
As
Integer
'ToDo: get charge id
Dim
subcategory
As
String
= TryCast(MyUserControl.FindControl(
"ddlSubcategories"
), DropDownList).SelectedValue
Dim
procedureCode
As
String
= TryCast(MyUserControl.FindControl(
"txtProcedureCode"
), TextBox).Text
Dim
displayCode
As
String
= TryCast(MyUserControl.FindControl(
"txtDisplayCode"
), TextBox).Text
Dim
description
As
String
= TryCast(MyUserControl.FindControl(
"txtDescription"
), TextBox).Text
Dim
minutes
As
String
= TryCast(MyUserControl.FindControl(
"txtMinutes"
), TextBox).Text
Dim
blnModifier
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresModifier"
), CheckBox).Checked
Dim
blnEpsdt
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresEPSDT"
), CheckBox).Checked
Dim
blnContMgmt
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresContraceptiveMgmt"
), CheckBox).Checked
Dim
blnNoMd
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxNoMdCharge"
), CheckBox).Checked
Dim
userMeditechId
As
String
= process.UserInfo_SDGenieMeditechID
If
IsNumeric(minutes) =
False
Then
minutes =
"0"
End
If
If
OCTools.AddChargeFormDefaultValue(
Me
.ddlEditClinic.SelectedValue,
Me
.ddlEditCategory.SelectedValue, subcategory, procedureCode, displayCode, description, minutes, blnModifier, blnEpsdt, blnContMgmt, blnNoMd) =
True
Then
Log(
"Inserted New Charge Info"
,
String
.Format(
"{0} inserted new charge info with ID {1}"
, process.UserInfo_SDGenieUserName, chgId))
Me
.UpdateUser(
"Insert"
)
Else
Me
.UpdateUser(
"Error"
)
End
If
End
If
Case
"Update"
Dim
MyUserControl
As
UserControl =
CType
(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
If
MyUserControl IsNot
Nothing
Then
Dim
id
As
String
= TryCast(MyUserControl.FindControl(
"lblID"
), Label).Text
Dim
subcategory
As
String
= TryCast(MyUserControl.FindControl(
"ddlSubcategories"
), DropDownList).SelectedValue
Dim
procedureCode
As
String
= TryCast(MyUserControl.FindControl(
"txtProcedureCode"
), TextBox).Text
Dim
displayCode
As
String
= TryCast(MyUserControl.FindControl(
"txtDisplayCode"
), TextBox).Text
Dim
description
As
String
= TryCast(MyUserControl.FindControl(
"txtDescription"
), TextBox).Text
Dim
minutes
As
String
= TryCast(MyUserControl.FindControl(
"txtMinutes"
), TextBox).Text
Dim
blnModifier
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresModifier"
), CheckBox).Checked
Dim
blnEpsdt
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresEPSDT"
), CheckBox).Checked
Dim
blnContMgmt
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxRequiresContraceptiveMgmt"
), CheckBox).Checked
Dim
blnNoMd
As
Boolean
= TryCast(MyUserControl.FindControl(
"cbxNoMdCharge"
), CheckBox).Checked
Dim
userMeditechId
As
String
= process.UserInfo_SDGenieMeditechID
If
OCTools.UpdChargeFormDefaultValue(
CInt
(id), subcategory, procedureCode, displayCode, description, minutes, blnModifier, blnEpsdt, blnContMgmt, blnNoMd) =
True
Then
Log(
"Updated Charge Info"
,
String
.Format(
"{0} updated charge info with ID {1}"
, process.UserInfo_SDGenieUserName, id))
Me
.UpdateUser(
"Update"
)
Else
Me
.UpdateUser(
"Error"
)
End
If
End
If
Case
"Delete"
Dim
id
As
Integer
= 0
Try
id =
DirectCast
((
DirectCast
(e.Item, GridDataItem)).GetDataKeyValue(
"id"
),
Integer
)
Catch
ex
As
Exception
End
Try
If
id > 0
Then
If
OCTools.DelChargeFormDefaultValue(id) =
True
Then
Log(
"Deleted Charge Info"
,
String
.Format(
"{0} deleted charge info with ID {1}"
, process.UserInfo_SDGenieUserName, id))
Me
.UpdateUser(
"Delete"
)
Else
Me
.UpdateUser(
"Error"
)
End
If
End
If
Case
Else
'Do Nothing
End
Select
End
Sub