Link to home
Create AccountLog in
Avatar of MartinChadderton
MartinChaddertonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

I have an edit button set up as a template field within a gridview and i want to edit that row if it is clicked but it is not firing the rowcomand event in the gridview.

aspx file:

<asp:TemplateField>
              <ItemTemplate>
                    <asp:Button ID="edit" runat="server"
                        CommandName="EditMilestones"
                        CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
                        Text="Edit" />
                </ItemTemplate>
            </asp:TemplateField>

code behind file

Protected Sub GrdVisualObjectives_RowCommand(ByVal sender As Object, _
          ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
        If (e.CommandName = "EditMilestones") Then
            ' Retrieve the row index stored in the CommandArgument property.
            Dim index As Integer = Convert.ToInt32(e.CommandArgument)

            ' Retrieve the row that contains the button
            ' from the Rows collection.
            Dim row As GridViewRow = GrdVisualObjectives.Rows(index)

            ' Add code here to add the item to the shopping cart.

        End If
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of ashokpumca
ashokpumca
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MartinChadderton

ASKER

It did