Basically I have a GridView:
<asp:GridView ID="gvServices" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AllowSorting="True"
AutoGenerateColumns="False" OnRowCommand="gvServices_RowCommand">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
And inside I have 2 TemplateFields:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnStart" runat="server" Text="Start" CommandName="StartService" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnStop" runat="server" Text="Stop" CommandName="StopService" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
</asp:TemplateField>
Finally I have the method thats supposed to fire when clicking on either of the Buttons on the gridView, problem is that when I click either of them the event does not get called at all
public void gvServices_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "StartService")
{
StartServiceItem(gvServices.Rows[index].Cells[0].Text, locations[index]);
}
if (e.CommandName == "StopService")
{
StopServiceItem(gvServices.Rows[index].Cells[0].Text, locations[index]);
}
loadGridView();
}