Batch Edit LinkButton opens a Popup window

This is a complete example of adding a linkbutton to a RadGrid in Batch Edit mode that will open a Popup window

Main Window

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="TEST.aspx.vb" Inherits="TEST" %>
 
<asp:Content ID="Content3" ContentPlaceHolderID="header" Runat="Server">
    <script type="text/javascript">
        //see the ItemCreated event for how this gets set up
        //opens a popup window, passes in the RowID param
        //'AddBaseDialog' is the name of the RadWindow, below
        function ShowEditForm(RowID, rowIndex) {
        var grid = $find("<%= RadGrid1.ClientID %>");
 
            var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
            grid.get_masterTableView().selectItem(rowControl, true);
 
            window.radopen("CycleCountsAdd.aspx?RowID=" + RowID, "AddBaseDialog");
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="lblError" runat="server" CssClass="error"></asp:Label>
    <telerik:RadAjaxPanel runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"  Width="1000px" RenderMode="Mobile" CssClass="Grid">
            <ClientSettings  AllowKeyboardNavigation="true">
                <ClientEvents OnBatchEditCellValueChanged="CellValueChanged" />
                <ClientEvents OnBatchEditOpening="BatchEditOpening" />
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
            </ClientSettings
            <MasterTableView DataKeyNames="itemnmbr, LOT,itmtrkop, RowID,COUNTEDQTY" EditMode="Batch" CommandItemDisplay="Top" >
                <BatchEditingSettings EditType="Cell" />
                <CommandItemSettings ShowAddNewRecordButton="false" />
                <Columns>
                   <telerik:GridTemplateColumn HeaderText="Item Number" UniqueName="colItemNumber" HeaderStyle-Width="500px" >
                        <ItemTemplate>
                            <asp:Label ID="lblItemNumber" Text='<%# Eval("itemnmbr") %>' runat="server"></asp:Label><br />
                            <asp:LinkButton runat="server"  CssClass="TextSmall" Text="Add Base UofM (Samples)" CommandName="ADDBASE" ID="btnAddBase"></asp:LinkButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadWindowManager RenderMode="Lightweight" ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow RenderMode="Lightweight" ID="AddBaseDialog" runat="server" Title="Add Base Quantity (Each, Sample)" Height="300px"
                    Width="500px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false"  VisibleStatusbar="false"
                    Modal="true">
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
    </telerik:RadAjaxPanel>
 
</asp:Content>

Code Behind

Imports System.Data
Imports System.Threading
Imports DynData
Imports Telerik.Web.UI
 
Partial Class TEST
    Inherits InheritedPage
 
    Private Sub utilities_SubordersOnHoldCredit2_Load(sender As Object, e As EventArgs) Handles Me.Load
 
    End Sub
 
 
    Private Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        Dim strError As String = ""
        Try
            Dim oDT As DataTable = DynData.SPs.fp_IV10301EXT_SEL_bySTCKCNTID5("TEST", "001", Nothing, App.ConnectionString).getTable
            Me.RadGrid1.DataSource = oDT
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
            Me.lblError.Text = ex.Message
 
        End Try
 
    End Sub
    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
        Dim strError As String = ""
        Try
            'set the ONCLICK properties of the AddBase link
            If TypeOf e.Item Is GridDataItem Then
                Dim editLink As LinkButton = DirectCast(e.Item.FindControl("btnAddBase"), LinkButton)
                editLink.Attributes("href") = "javascript:void(0);"
                Dim intRowID As Int32 = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("RowID")
                editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", intRowID, e.Item.ItemIndex)
            End If
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
            Me.lblError.Text = ex.Message
 
        End Try
 
 
    End Sub
 
 
End Class

Popup window

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CycleCountsAddBase.aspx.vb" Inherits="Delivery_CycleCountsAddBase" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="/Skins/TabletSkin/Button.TabletSkin.css" type="text/css" runat="server" id="Link1" />
    <link rel="stylesheet" href="/cssTablet/Tablet.css" type="text/css" runat="server" id="Stylesheet1"  />
    <link rel="stylesheet" href="/cssTablet/TabletCommon.css"  />
    <link rel="stylesheet" href="/cssTablet/Tablet RadTextBox.css"  />
    <link rel="stylesheet" href="/cssTablet/Tablet RadButton.css"  />
 
    <script type="text/javascript">
        function CloseAndRebind(args)
        {
            //GetRadWindow().BrowserWindow.refreshGrid(args);
            GetRadWindow().close();
        }
   
        function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
   
            return oWindow;
        }
   
        function CancelEdit()
        {
            GetRadWindow().close();
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager Runat="server" ID="ScriptManager">
        </telerik:RadScriptManager>
        <div>
            <asp:Label runat="server" ID="lblError"></asp:Label>
            <br /><br />
             <table class="table0">
                <tr>
                    <td class="table1">Add <label runat="server" id="lblBaseUofM"></label> Quantities
                    </td>
                    <td class="table2"><telerik:RadNumericTextBox runat="server" ID="ntbQuantity" ></telerik:RadNumericTextBox>
                    </td>
                </tr>
 
 
                <tr>
                    <td colspan="2" class="table2"><telerik:RadButton runat="server" ID="btnSave" Text="Add"></telerik:RadButton>
                    </td>
                </tr>
            </table>
            
        </div>
    </form>
</body>
</html>

Popup Code Behind

Imports System.Threading
 
Partial Class Delivery_CycleCountsAddBase
    Inherits InheritedPage
 
    Dim mintRowID As Int32
    Private Sub Delivery_CycleCountAdd_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim strError As String = ""
        Try
            mintRowID = Request("RowID")
            If Not IsPostBack Then
                Dim oIV10301EXT As New DynData.IV10301EXT(mintRowID, App.ConnectionString)
                If Not oIV10301EXT.isPopulated Then
                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
                End If
                Dim strItemNumber As String = oIV10301EXT.ITEMNMBR
 
                Dim oIV00101 As New DynData.IV00101(strItemNumber, App.ConnectionString)
                If Not oIV00101.isPopulated Then
                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
                End If
                Dim strUomSchedule As String = oIV00101.UOMSCHDL
 
                Dim oIV40201 As New DynData.IV40201(strUomSchedule, App.ConnectionString)
                If Not oIV40201.isPopulated Then
                    ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
                End If
                Dim strUofMBase As String = oIV40201.BASEUOFM
 
            End If
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
            Me.lblError.Text = ex.Message
 
        End Try
 
    End Sub
 
    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Dim strError As String = ""
        Try
            Dim decQuantity As Decimal = ntbQuantity.Value
 
 
            'get a reference to the calling form
            Dim oIV10301EXT As New DynData.IV10301EXT(mintRowID, App.ConnectionString)
            If oIV10301EXT.isPopulated Then
                oIV10301EXT.COUNTEDQTY += decQuantity
                oIV10301EXT.Save(App.ConnectionString)
            End If
 
            'close the window
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
 
        Catch ex As ThreadAbortException
        Catch ex As Exception
            ErrorHandler.globalErrorHandler(ex, strError, App.AppName, App.UserName, False)
            Me.lblError.Text = ex.Message
 
        End Try
 
    End Sub
End Class

 

 

 

 

 

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences