2
Initially make the buttons visibility as false.
<asp:Button ID="StartJob" runat="server" Text="Start" CommandName="Start_Cleanup" Visible="false" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
<asp:Button ID="StopJob" runat="server" Text="Stop" CommandName="Stop_Cleanup" Visible="false" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
In Row DataBound Event
check the database for whether the job is running or stopped
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Button btnStart = e.Row.FindControl("Button1") as Button;
// Button btnStop = e.Row.FindControl("Button2") as Button;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if(job is running)
{
btnStop.Visible = true;
}
else
{
btnStart.Visible = true;
}
}
Accepted 0
This put me on the right track, thanks alot Madhu. :)