I have a template field in my gridview which holds a button for each row, however when I test it to see if it's working it doesn't do anything, the page just reloads but nothing has happened. What I want the button to do in the end is to unlock a user. At the minute I'm testing it by having a panel appear if the button is clicked.

  <asp:TemplateField>
                <ItemTemplate>
                    <asp:Button ID="btnUnlock" runat="server" CommandArgument='<%# Eval("UserId") %>'
                        CommandName="Select" Text="Unlock" OnCommand="btnUnlock_Command"/>
                </ItemTemplate>
            </asp:TemplateField>

This is the part of the gridview for the button, not sure for the code behind should I use the button onCommand method or gridview rowCommand method?

Recommended Answers

All 2 Replies

Yes but this was a different problem I was having with the page. Was able to sort it, just needed a clean refresh of the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.