Hi
I am not able to get the changed values in the controls in edit mode when I am using either "Popup" (or editforms) modes. Using 'GridEditFormItem' to retrieve the values and it returns old value and not the changed ones. Here is my code:
======================================================================
ASPX:
=================================================================
<telerik:RadGrid ID="radFootNotes" runat="server" Width="100%" AutoGenerateColumns="false" BackColor="Beige" AllowPaging="false" AllowSorting="false" OnItemCommand="radFootNotes_ItemCommand" onneeddatasource="radFootNotes_NeedDataSource" >
<MasterTableView AutoGenerateColumns="false" DataKeyNames="FootNoteID" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="PopUp" CommandItemDisplay="TopAndBottom" CommandItemSettings-AddNewRecordText="Add Footnote">
<Columns>
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> <telerik:GridBoundColumn UniqueName="FootNoteText" DataField="FootNoteText" HeaderText="Foot Note" ReadOnly="true" /> <telerik:GridButtonColumn ConfirmDialogType="RadWindow" CommandName="Rules" ConfirmDialogHeight="100px" ConfirmDialogWidth="220px" Text="Rules"></telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template" PopUpSettings-Width="400px">
<PopUpSettings Height="500" Width="800" Modal="true" /> <FormTemplate>
<table>
<tr><td class="style1">Disclosure Number</td><td><asp:TextBox ID="txtDisclosureNumber" Text='<%# Eval("DisclosureNumber") %>' runat="server" ></asp:TextBox></td></tr>
<tr><td class="style1">FootNote Text</td><td><asp:TextBox ID="txtFootnoteText" Text='<%# Eval("FootnoteText") %>' runat="server" Height="150px" TextMode="MultiLine" Width="670px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Name</td><td><asp:TextBox ID="txtFontName" Text='<%# Eval("FontName") %>' runat="server" Width="197px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Size</td><td><asp:TextBox ID="txtFontSize" Text='<%# Eval("FontSize") %>' runat="server" Width="195px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Color</td><td><asp:TextBox ID="txtFontColor" Text='<%# Eval("FontColor") %>' runat="server" Width="196px" ></asp:TextBox></td></tr>
<tr><td class="style1">List Order</td><td><asp:TextBox ID="txtListOrder" Text='<%# Eval("ListOrder") %>' runat="server" Width="30px" ></asp:TextBox></td></tr>
<tr><td class="style1">Is Active</td><td><asp:CheckBox ID="chkActive" Checked='<%# Eval("IsActive") %>' DataField="IsActive" HeaderText="Active" UniqueName="IsActive" runat="server"></asp:CheckBox></td></tr>
<tr><td class="style1"></td><td><br /></td></tr>
<tr><td class="style1"></td><td> <asp:Button ID="btnUpdate" runat="server" Text='<%# IIf (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>' CommandName='<%# IIf (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'></asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"/>
</td></tr> </table>
</FormTemplate> </EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
</telerik:RadGrid>
==================================================================
VB:
==================================================================
Protected Sub radFootNotes_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles radFootNotes.ItemCommand
If e.CommandName = RadGrid.InitInsertCommandName Then '"Add new" button clicked
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
editColumn.Visible = False
ElseIf (e.CommandName = RadGrid.RebindGridCommandName AndAlso e.Item.OwnerTableView.IsItemInserted) Then
e.Canceled = True
ElseIf e.CommandName = "Update" Then
If (TypeOf e.Item Is GridEditableItem) AndAlso e.Item.IsInEditMode Then
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim footnoteID As Integer = Item.GetDataKeyValue("FootNoteID")
'Dim dr As dsFootNote.ReportFootNoteRulesRow = ds.ReportFootNoteRules.NewReportFootNoteRulesRow
Dim dr As dsFootNote.ReportFootNotesRow = ds.ReportFootNotes.FindByFootNoteID(footnoteID)
''Dim editDataitem As GridDataItem = e.Item
'Dim editform As GridEditFormItem = CType(CType(e.Item, GridDataItem).EditFormItem, GridEditFormItem)
'Dim ditem As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Dim editform As GridEditFormItem = CType(e.Item, GridEditFormItem) 'Dim editTable As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim DisclosureNumber As String = TryCast(editform.FindControl("txtDisclosureNumber"), TextBox).Text
Dim FootNoteText As String = TryCast(editform.FindControl("txtFootNoteText"), TextBox).Text
Dim FontName As String = TryCast(editform.FindControl("txtFontName"), TextBox).Text
Dim FontSize As String = TryCast(editform.FindControl("txtFontSize"), TextBox).Text
Dim FontColor As String = TryCast(editform.FindControl("txtFontColor"), TextBox).Text
Dim ListOrder As String = TryCast(editform.FindControl("txtListOrder"), TextBox).Text
Dim IsActive As Boolean = TryCast(editform.FindControl("chkIsActive"), CheckBox).Checked
dr.FootNoteID = footnoteID
If String.IsNullOrEmpty(DisclosureNumber) Then
dr.SetDisclosureNumberNull()
Else
dr.DisclosureNumber = DisclosureNumber
End If
dr.FootNoteText = FootNoteText
dr.FontName = FontName
dr.FontSize = FontSize
dr.FontColor = FontColor
dr.ListOrder = ListOrder
dr.IsActive = IsActive
'Save Footnote
OCS.DAL.FootNotes.FootNotes.UpdateReportFootNotes(ds, 2)
'Rebind the FootNotes Grid
ds = OCS.DAL.FootNotes.FootNotes.GetReportFootNotes(0, 0, 2)
radFootNotes.Rebind()
'Close PopUp
radFootNotes.MasterTableView.ClearEditItems()
End If
ElseIf e.CommandName = "Cancel" Then
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
editColumn.Visible = False
Else
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible = True
End If
End If
End Sub
Can I get some help??
I am not able to get the changed values in the controls in edit mode when I am using either "Popup" (or editforms) modes. Using 'GridEditFormItem' to retrieve the values and it returns old value and not the changed ones. Here is my code:
======================================================================
ASPX:
=================================================================
<telerik:RadGrid ID="radFootNotes" runat="server" Width="100%" AutoGenerateColumns="false" BackColor="Beige" AllowPaging="false" AllowSorting="false" OnItemCommand="radFootNotes_ItemCommand" onneeddatasource="radFootNotes_NeedDataSource" >
<MasterTableView AutoGenerateColumns="false" DataKeyNames="FootNoteID" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="PopUp" CommandItemDisplay="TopAndBottom" CommandItemSettings-AddNewRecordText="Add Footnote">
<Columns>
<telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> <telerik:GridBoundColumn UniqueName="FootNoteText" DataField="FootNoteText" HeaderText="Foot Note" ReadOnly="true" /> <telerik:GridButtonColumn ConfirmDialogType="RadWindow" CommandName="Rules" ConfirmDialogHeight="100px" ConfirmDialogWidth="220px" Text="Rules"></telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template" PopUpSettings-Width="400px">
<PopUpSettings Height="500" Width="800" Modal="true" /> <FormTemplate>
<table>
<tr><td class="style1">Disclosure Number</td><td><asp:TextBox ID="txtDisclosureNumber" Text='<%# Eval("DisclosureNumber") %>' runat="server" ></asp:TextBox></td></tr>
<tr><td class="style1">FootNote Text</td><td><asp:TextBox ID="txtFootnoteText" Text='<%# Eval("FootnoteText") %>' runat="server" Height="150px" TextMode="MultiLine" Width="670px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Name</td><td><asp:TextBox ID="txtFontName" Text='<%# Eval("FontName") %>' runat="server" Width="197px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Size</td><td><asp:TextBox ID="txtFontSize" Text='<%# Eval("FontSize") %>' runat="server" Width="195px" ></asp:TextBox></td></tr>
<tr><td class="style1">Font Color</td><td><asp:TextBox ID="txtFontColor" Text='<%# Eval("FontColor") %>' runat="server" Width="196px" ></asp:TextBox></td></tr>
<tr><td class="style1">List Order</td><td><asp:TextBox ID="txtListOrder" Text='<%# Eval("ListOrder") %>' runat="server" Width="30px" ></asp:TextBox></td></tr>
<tr><td class="style1">Is Active</td><td><asp:CheckBox ID="chkActive" Checked='<%# Eval("IsActive") %>' DataField="IsActive" HeaderText="Active" UniqueName="IsActive" runat="server"></asp:CheckBox></td></tr>
<tr><td class="style1"></td><td><br /></td></tr>
<tr><td class="style1"></td><td> <asp:Button ID="btnUpdate" runat="server" Text='<%# IIf (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>' CommandName='<%# IIf (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'></asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"/>
</td></tr> </table>
</FormTemplate> </EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick" />
</ClientSettings>
</telerik:RadGrid>
VB:
==================================================================
Protected Sub radFootNotes_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles radFootNotes.ItemCommand
If e.CommandName = RadGrid.InitInsertCommandName Then '"Add new" button clicked
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
editColumn.Visible = False
ElseIf (e.CommandName = RadGrid.RebindGridCommandName AndAlso e.Item.OwnerTableView.IsItemInserted) Then
e.Canceled = True
ElseIf e.CommandName = "Update" Then
If (TypeOf e.Item Is GridEditableItem) AndAlso e.Item.IsInEditMode Then
Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim footnoteID As Integer = Item.GetDataKeyValue("FootNoteID")
'Dim dr As dsFootNote.ReportFootNoteRulesRow = ds.ReportFootNoteRules.NewReportFootNoteRulesRow
Dim dr As dsFootNote.ReportFootNotesRow = ds.ReportFootNotes.FindByFootNoteID(footnoteID)
''Dim editDataitem As GridDataItem = e.Item
'Dim editform As GridEditFormItem = CType(CType(e.Item, GridDataItem).EditFormItem, GridEditFormItem)
'Dim ditem As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Dim editform As GridEditFormItem = CType(e.Item, GridEditFormItem) 'Dim editTable As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim DisclosureNumber As String = TryCast(editform.FindControl("txtDisclosureNumber"), TextBox).Text
Dim FootNoteText As String = TryCast(editform.FindControl("txtFootNoteText"), TextBox).Text
Dim FontName As String = TryCast(editform.FindControl("txtFontName"), TextBox).Text
Dim FontSize As String = TryCast(editform.FindControl("txtFontSize"), TextBox).Text
Dim FontColor As String = TryCast(editform.FindControl("txtFontColor"), TextBox).Text
Dim ListOrder As String = TryCast(editform.FindControl("txtListOrder"), TextBox).Text
Dim IsActive As Boolean = TryCast(editform.FindControl("chkIsActive"), CheckBox).Checked
dr.FootNoteID = footnoteID
If String.IsNullOrEmpty(DisclosureNumber) Then
dr.SetDisclosureNumberNull()
Else
dr.DisclosureNumber = DisclosureNumber
End If
dr.FootNoteText = FootNoteText
dr.FontName = FontName
dr.FontSize = FontSize
dr.FontColor = FontColor
dr.ListOrder = ListOrder
dr.IsActive = IsActive
'Save Footnote
OCS.DAL.FootNotes.FootNotes.UpdateReportFootNotes(ds, 2)
'Rebind the FootNotes Grid
ds = OCS.DAL.FootNotes.FootNotes.GetReportFootNotes(0, 0, 2)
radFootNotes.Rebind()
'Close PopUp
radFootNotes.MasterTableView.ClearEditItems()
End If
ElseIf e.CommandName = "Cancel" Then
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
editColumn.Visible = False
Else
Dim editColumn As GridEditCommandColumn = CType(radFootNotes.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
If Not editColumn.Visible Then
editColumn.Visible = True
End If
End If
End Sub