RadConfirm with grid itemdatabound

3 posts, 1 answers
  1. usr9999
    usr9999 avatar
    41 posts
    Member since:
    Jun 2010

    Posted 17 Jul 2010 Link to this post

    I have the following is my grid template column and the code behind grid databound and item command.

    How can i add radconfim to the same? When user chooses yes, i want the code in item command to execute. 

    <telerik:GridTemplateColumn UniqueName="Retrieve"> 

    <ItemTemplate><asp:LinkButton ID="lnkRetrieve" runat="server" CausesValidation="false" CommandArgument='<%# cstr(Eval("id"))%>'  CommandName="Retrieve" Text="Retrieve"></asp:LinkButton>
    </ItemTemplate>
    </telerik:GridTemplateColumn>

    Private Sub grd_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grd.ItemDataBound If TypeOf e.Item Is GridDataItem Then
    Dim llnkRetrieve As New LinkButton
      llnkRetrieve =
    CType(e.Item.FindControl("lnkRetrieve"), LinkButton)
    llnkRetrieve.Attributes.Add(
    "onclick", "return confirm('Are you sure you want to retrieve?');")
    End If 

    End Sub

     

    Protected 

     

    Sub grd_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grd.ItemCommand
    If e.CommandName = "Retrieve" Then
    dim CommandArgument As String() = e.CommandArgument.ToString().Split(",")
      Session(
    "ID") = CInt(CommandArgument(0))

     Respose.Redirect(

    "Page.aspx", True) End If
    End Sub

     

     

  2. usr9999
    usr9999 avatar
    41 posts
    Member since:
    Jun 2010

    Posted 19 Jul 2010 Link to this post

    Help Please!-
  3. Answer
    Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 22 Jul 2010 Link to this post

    Hello usr9999,

    In order to get the desired result you should go through the following steps:

    1) Cancel the postback of the button (this is needed because the radconfirm does not block the thread) as shown below:

    llnkRetrieve.Attributes.Add("onclick", "confirm('Are you sure you want to retrieve?',  confirmCallBackFn);return false")

    2) Use a client javascript callback function as shown above

    3) Check the argument of in the callback and do the corresponding operation (e.g if you need to make a server call use the built-in javascript __doPostBack function as explained here: http://geekswithblogs.net/mnf/archive/2005/11/04/59081.aspx)

    Detailed help article about radconfirm and how to use it is available below:

    http://www.telerik.com/help/aspnet-ajax/window_dialogsconfirm.html

    A sample demo is uploaded here:

    http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspx

    I hope that my explanations and the provided resources are helpful, let me know how it goes.

    Best wishes,
    Svetlina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top