hi!
below is the code of what i have tried so far
My database has a table called stages with IdStage, IdState
and one called states with IdState and Name (inProgress, inWaiting and Finished)
I need to update only one cell in a gridview at Take task button click. When i click that button the row must be colored red and the state cell must change its state to inProgress and the button must disappear.
I managed to color the row at button click but have no idea how to update the cell at the same time.. please help i'm kind of new at this.
Thank you and i hope i made myself clear with my question
What I have tried:
the aspx
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<asp:Button ID="btnTake" runat="server" Text="Take task" OnClick="btnTake_Click" />
</ItemTemplate>
</asp:TemplateField>
the aspx.cs
protected void btnTake_Click(object sender, EventArgs e)
{
string sqlUpdateState = "update stages set IdState=1 where IdStage = ?? "; (don't know what i'm supposed to say here to change only the state of clicked row )
DataTable dt = GetData(sqlUpdateState);
gvActivities.DataSource = dt;
Button btnTake = (Button)sender;
GridViewRow row = (GridViewRow)btnTake.NamingContainer;
row.BackColor = System.Drawing.Color.Red;
btnTake.Visible = false;
}