This is a migrated thread and some comments may be shown as answers.

Can not get Update Button to work.

3 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 1
Kris asked on 10 Nov 2010, 10:32 PM
Below I have an image of my running page.

I have my Update button in Edit.ascx
  
<td align="right">
             <asp:Button ID="btnUpdate" Text="Update" runat="server" 
                 CommandName="Update" 
                 Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>'>
            </asp:Button>
  
    
            <asp:button id="btnCancel" text="Cancel" runat="server" causesvalidation="False" commandname="Cancel"></asp:button>
            </td>
  
And I have my server side code: in exit.ascx.vb
  
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
        'Set Varibles
.
.
.
End Sub
  
Telerick grid in view.ascx
.
.
.
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                    </telerik:GridEditCommandColumn>
  
    </Columns>
    <EditFormSettings UserControlName="desktopModules/AAUMembershipHist01/Edit.ascx" EditFormType="WebUserControl">
        <EditColumn UniqueName="EditCommandColumn1">
        </EditColumn>
    </EditFormSettings>
.
.
.
  
Running my trace I find that the Server side code never gets executed.
  
Doing something wrong.  Can someone point my in the right direction?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2010, 12:47 PM

Hello Kris,


From your code given, I cannot see that you attached the onclick event to the 'Update' button.

Mark-up:

<asp:Button ID="Button1" Text="Update" runat="server" CommandName="Update"
    onclick="btnUpdate_Click" >
</asp:Button>


A better method is handling Update in ItemCommand/UpdateComand event of grid. In the ItemCommand event of RadGrid you can write code for 'Update' operation.

VB.Net:

Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs)
   If e.CommandName = "Update" Then
        ' your code
   End If
End Sub



Thanks,

Princy.

0
Kris
Top achievements
Rank 1
answered on 11 Nov 2010, 03:55 PM
Thanks but but that did not work.

My Grid is located in view.ascx and my form is in edit.ascx.

my view.ascx.vb has
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
        If (e.CommandName = RadGrid.UpdateCommandName) Then
            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        End If
        If e.CommandName = "Update" Then
            ' your code 
            If 1 = 2 Then Dim test As Integer = 1
        End If
  
    End Sub

I added e.CommandName = "Update" Then but the sub proc. does not get triggered when you clik it.

My Code in edit.ascx for the button is:
<asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>'> 
</asp:Button>

Thanks for your quick response.
0
Kris
Top achievements
Rank 1
answered on 11 Nov 2010, 10:37 PM
Thanks all, I found my error.  It had nothing to do with the RadGrid.
Tags
Grid
Asked by
Kris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kris
Top achievements
Rank 1
Share this question
or