0
votes

I am developing an ASP.Net Website. I used GridView to display some information which in the database. Moreover, I put a button on each row in the GridView and set the CommandName of the button.

In the web page:

asp:Button ID="btnShip" runat="server" CommandArgument='<%#Eval("Invoice_No") %>' CommandName="Ship" Text="Ship" Visible="True"

And then I create a VB function to handle the GridViewCommandEventArgs of this GridView. This is the following coding:

Protected Sub Purchase_Process_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView1.RowCommand

If e.CommandName = "Ship" Then .....

Basically, it should do something If I press the button with CommandName "Ship". However, it doesn't work. I tried to create a empty webpage and then copy the code into that page. It was working fine for a little moment...

I also put a MsgBox() before the If statement and I found the function won't execute when I press the button in the GridView.

1

1 Answers

0
votes

check in the grid properties there should be Purchase_Process_RowCommand in the ASP code

   <asp:GridView ID="Purchase_Process" runat="server"
     OnRowCommand="Purchase_Process_RowCommand">
       <asp:TemplateField>
         <ItemTemplate>
         <asp:Button runat="server" ID="Invoice" Text="Edit Information"
          CommandName="Invoice" CommandArgument=<%# Eval("Invoice_No") %> />
         </ItemTemplate>
        </asp:TemplateField>
    </asp:GridView>