动态Radgrid ItemCommand

时间:2018-07-02 07:30:23

标签: vb.net grid telerik controls radgrid

我以编程方式制作了一个动态RadGrid。在每一行上,我都会创建一个用于编辑该行的图像按钮。当我单击图像按钮时,itemcommand会正确触发并打开用于编辑的表单,但是当我在编辑表单中按更新按钮时,不会触发itemcommand。

关于我的问题有什么想法吗?

Private Sub Queue_Init(sender As Object, e As EventArgs) Handles Me.Init
   Dim grid As RadGrid = New RadGrid()
            grid.ID = "Radgrid" + item.STRC_TEAM_ID

            grid.MasterTableView.AllowAutomaticUpdates = True

            AddHandler grid.ItemCommand, AddressOf grid_ItemCommand

            grid.AutoGenerateColumns = False

            grid.ClientSettings.EnablePostBackOnRowClick = True
   grid.DataSource = cyinboxresults

 Dim NewColumn = New GridBoundColumn()
            NewColumn.DataField = "INBOX_ID"
            NewColumn.UniqueName = "INBOX_ID"
            NewColumn.HeaderText = "INBOX_ID"
            NewColumn.Display = False
            grid.MasterTableView.Columns.Add(NewColumn)

     Dim templateColumnName As String = "edit"
            Dim templateColumn As New GridTemplateColumn()
            templateColumn.ItemTemplate = New MyTemplate(templateColumnName)
            templateColumn.HeaderText = templateColumnName

            grid.MasterTableView.Columns.Add(templateColumn)
 grid.DataBind()
End Sub
 Private Class MyTemplate
        Implements ITemplate
        Protected lControl As LiteralControl
        Protected textBox As ImageButton
        Private colname As String
        Public Sub New(ByVal cName As String)
            colname = cName
        End Sub
        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn
            lControl = New LiteralControl()
            lControl.ID = "lControl"
            ' AddHandler lControl.DataBinding, AddressOf lControl_DataBinding
            textBox = New ImageButton()
            textBox.ID = "editTextBox"
            textBox.ImageUrl = "~/images/pencil_20.gif"
            textBox.CommandArgument = "Edit"
            textBox.CommandName = "Edit"

            AddHandler textBox.Click,
              AddressOf textBox_Click


            '  AddHandler boolValue.DataBinding,
            '    AddressOf boolValue_DataBinding

            container.Controls.Add(textBox)

        End Sub
        Sub textBox_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim cBox As ImageButton = DirectCast(sender, ImageButton)
            Dim container As GridDataItem = DirectCast(cBox.NamingContainer, GridDataItem)
            'container.GetDataKeyValue("")

            'cBox.Checked = DirectCast((DirectCast(container.DataItem, DataRowView))("Bool"), Boolean)
        End Sub



 Protected Sub grid_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)

        If e.CommandName = "PerformInsert" Then

        ElseIf e.CommandName = "Edit" Then

        End If

    End Sub

0 个答案:

没有答案