I'm using the edit form template to accomplish what I need to do but I'm running into 1 snag.
Here is my relevant code:
My problem is when I click the btnUpdate button the Item_Created Sub is run first resetting any values that where changed. I've tried initiating my template forms in the edit_command sub but they don't exist yet. Is it possible to do what I want?
Here is my relevant code:
<EditFormSettings EditFormType="Template"> |
<FormTemplate> |
<div style="padding:25px; height:70px;"> |
<div style="width:100%; float:left; margin:0 auto; text-align:center; display:inline; "> |
<asp:Label ID="lblBw" runat="server" Text="B/W Volume: " /> |
<telerik:RadNumericTextBox ID="rtxtBwVolume" runat="server" CssClass="AlignRight" |
Culture="English (United States)" InvalidStyleDuration="100" MaxValue="100000" |
MinValue="0" ShowSpinButtons="True" Value="1000" Width="75px" > |
<IncrementSettings Step="1000" /> |
<NumberFormat AllowRounding="True" DecimalDigits="0"></NumberFormat> |
</telerik:RadNumericTextBox> |
<asp:Label ID="lblColor" runat="server" Text="Color Volume: " /> |
<telerik:RadNumericTextBox ID="rtxtColorVolume" runat="server" CssClass="AlignRight" |
Culture="English (United States)" InvalidStyleDuration="100" MaxValue="100000" |
MinValue="0" ShowSpinButtons="True" Value="1000" Width="75px" > |
<IncrementSettings Step="1000" /> |
<NumberFormat AllowRounding="True" DecimalDigits="0"></NumberFormat> |
</telerik:RadNumericTextBox> |
<asp:label ID="lblUnits" runat="server" Text="Units: " Visible="false"/> |
<asp:RadioButtonList ID="rblUnits" runat="server" RepeatLayout="flow" |
RepeatDirection="horizontal" EnableTheming="false" Visible="false" > |
<asp:ListItem Value="3" Text="Feet" /> |
<asp:ListItem Value="4" Text="Meters" /> |
</asp:RadioButtonList> |
</div> |
<div style="width:100%; float:left; margin:0 auto; text-align:center; "> |
<asp:CheckBox ID="chkNoWarranty" runat="server" Text="No Warranty" /> |
<asp:CheckBox ID="chkFiery" runat="server" Text="Fiery" /> |
<asp:CheckBox ID="chkNewCustomer" runat="server" Text="New Customer" /> |
</div> |
<div style="width:100%; float:left; margin:0 auto; text-align:center; "> |
<asp:Button runat="server" ID="btnUpdate" Text="Update" CommandName="Update" /> |
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> |
</div> |
</div> |
<asp:Panel ID="pnlError" runat="server" > |
<div style="text-align:center;"><asp:PlaceHolder id="PlaceHolder1" runat="server" /></div> |
<div style="text-align:center; color:Red;"><des:ValidationSummary ID="ValidationSummary1" runat="server" Group="Volume" /></div> |
</asp:Panel> |
</FormTemplate> |
</EditFormSettings> |
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
If (TypeOf e.Item Is GridEditableItem) AndAlso (e.Item.IsInEditMode) Then |
Dim editItem As GridEditableItem = TryCast(e.Item, GridEditableItem) |
Dim txtbx As RadNumericTextBox = DirectCast(editItem.FindControl("rtxtBwVolume"), RadNumericTextBox) |
Dim ent As MaPlansEquipmentEntity = MAM.GetMaEquipmentWithRates(editItem.GetDataKeyValue("MaPlansEquipmentId")) |
Dim chkWarranty As CheckBox = DirectCast(editItem.FindControl("chkNoWarranty"), CheckBox) |
Dim chkFiery As CheckBox = DirectCast(editItem.FindControl("chkFiery"), CheckBox) |
Dim chkNewCust As CheckBox = DirectCast(editItem.FindControl("chkNewCustomer"), CheckBox) |
chkWarranty.Checked = ent.NoWarrantyYn |
chkFiery.Checked = ent.FieryYn |
chkNewCust.Checked = ent.NewCustYn |
Dim lblBw As Label = DirectCast(editItem.FindControl("lblBw"), Label) |
Dim lblColor As Label = DirectCast(editItem.FindControl("lblColor"), Label) |
Dim lblUnits As Label = DirectCast(editItem.FindControl("lblUnits"), Label) |
Dim rtxtBwVolume As RadNumericTextBox = DirectCast(editItem.FindControl("rtxtBwVolume"), RadNumericTextBox) |
Dim rtxtColorVolume As RadNumericTextBox = DirectCast(editItem.FindControl("rtxtColorVolume"), RadNumericTextBox) |
Dim rblUnits As RadioButtonList = DirectCast(editItem.FindControl("rblUnits"), RadioButtonList) |
rblUnits.SelectedValue = 3 |
End If |
End Sub |
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
If e.CommandName = "Update" Then |
Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) |
Dim Id As Integer = editItem.GetDataKeyValue("MaPlansEquipmentRateId") |
Dim rtxtBwVolume As RadNumericTextBox = DirectCast(editItem.FindControl("rtxtBwVolume"), RadNumericTextBox) |
Dim rtxtColorVolume As RadNumericTextBox = DirectCast(editItem.FindControl("rtxtColorVolume"), RadNumericTextBox) |
Dim rblUnits As RadioButtonList = DirectCast(editItem.FindControl("rblUnits"), RadioButtonList) |
Dim chkWarranty As CheckBox = DirectCast(editItem.FindControl("chkNoWarranty"), CheckBox) |
Dim chkFiery As CheckBox = DirectCast(editItem.FindControl("chkFiery"), CheckBox) |
Dim chkNewCust As CheckBox = DirectCast(editItem.FindControl("chkNewCustomer"), CheckBox) |
Try |
MAM.UpdateMachineNew(Id, rtxtBwVolume.Value, rtxtColorVolume.Value, rblUnits.SelectedValue, _ |
chkWarranty.Checked, chkFiery.Checked, chkNewCust.Checked, Profile.UserId) |
e.Item.Edit = False |
Me.RadGrid1.Rebind() |
Catch ex As Exception |
'Error code here |
End Try |
End If |
End Sub |
My problem is when I click the btnUpdate button the Item_Created Sub is run first resetting any values that where changed. I've tried initiating my template forms in the edit_command sub but they don't exist yet. Is it possible to do what I want?