Dynamic Datagrid Creation - ItemCommand event not firing

Discussion in 'ASP .Net Datagrid Control' started by PD, Oct 23, 2003.

  1. PD

    PD Guest

    I am generating a dynamic datagrid that gets assigned to a cell within
    the parent grid. Here's the html:

    <asp:DataGrid id="dgPositions" runat="server" Width="710"
    CellPadding="3" HeaderStyle-Font-Bold="True" CssClass="inputfields"
    AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn></asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>

    I have a custom control within the child grid that inherits from the
    ImageButton control:

    With cb
    .ToolTip = "Remove"
    .CausesValidation = False
    .ImageUrl = "images/delete_s1.gif"
    .Message = "Are you sure you want to delete
    this?"
    .ID = "btnRemove"
    .AlternateText = "Remove"
    .CommandName = "Delete"
    End With
    container.Controls.Add(cb)

    The child grid is constructed within the dgPositions_ItemDataBound
    function of the parent grid.

    dgNewGrid.HeaderStyle.Font.Bold = True
    dgNewGrid.CellPadding = 3
    dgNewGrid.CssClass = "inputfields"
    dgNewGrid.AutoGenerateColumns = False
    dgNewGrid.ID = "gridPositions"
    AddHandler dgNewGrid.ItemCommand, AddressOf
    dgPositions_ItemCommand2
    dgi.Cells(0).Controls.Add(dgNewGrid)


    I want the dgPositions_ItemCommand2 to kick off when the user clicks
    on the custom control (cb) above. The code to
    dgPositions_ItemCommand2:

    Public Sub dgPositions_ItemCommand2(ByVal sender As Object, ByVal
    e As System.Web.UI.WebControls.DataGridCommandEventArgs)
    Try
    If e.CommandName = "Delete" Then
    Response.Write("Test")
    End If
    Catch ex As Exception
    Response.Write(ex.Message)
    End Try
    End Sub

    I have not been successful in getting the dgPositions_ItemCommand2
    code to kick off. Any thoughts/suggestions would be greatly
    appreciated!!

    Thanks,
    Patrick
    PD, Oct 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGVlcGVzaA==?=

    Datagrid ItemCommand Event Not Firing

    =?Utf-8?B?RGVlcGVzaA==?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,792
    =?Utf-8?B?RGVlcGVzaA==?=
    Oct 6, 2005
  2. EvelynAnd Ethan
    Replies:
    4
    Views:
    967
    =?Utf-8?B?Sko=?=
    Jan 9, 2006
  3. EvelynAnd Ethan
    Replies:
    0
    Views:
    395
    EvelynAnd Ethan
    Oct 17, 2005
  4. EvelynAnd Ethan
    Replies:
    0
    Views:
    540
    EvelynAnd Ethan
    Oct 17, 2005
  5. =?Utf-8?B?ZGFuYw==?=

    DataGrid ItemCommand event not firing if not first page

    =?Utf-8?B?ZGFuYw==?=, Oct 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,142
    =?Utf-8?B?ZGFuYw==?=
    Oct 26, 2005
Loading...

Share This Page