1

I have a gridview with columns Action, Sigin Date and Signout date. The "Action Column" is a button field column. For every cell in the Signout date column, i want the button in the same row with the signout date to be enabled. If there is signout date, i want the button to be disabled. How do i do this?

Mcbaloo
  • 157
  • 5
  • 18
  • Possible duplicate of [Conditionally hide CommandField or ButtonField in Gridview](http://stackoverflow.com/questions/1461302/conditionally-hide-commandfield-or-buttonfield-in-gridview) – lubilis Oct 10 '16 at 08:54

1 Answers1

1

Example code before i have used in My project

   <asp:Button CommandName="del" ID="btnDisable" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'
                                                        CssClass="btn btn-danger btn-xs disable" />

 if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    // HIGHTLIGHT ACTIVE/INACTIVE USERS
                    Label lblStatus = (Label)e.Row.FindControl("lblStatus");
                    Button del = (Button)e.Row.FindControl("btnDisable");
                    if (lblStatus.Text == "False")
                    {
                        lblStatus.CssClass = "label label-success disabled";
                        lblStatus.Text = "Active";
                        del.Text = "Disable";
                    }
                    else
                    {

                        lblStatus.CssClass = "label label-danger disabled";
                        lblStatus.ToolTip = "User is inactive.";
                        lblStatus.Text = "Inactive";
                        del.Text = "Enable";
                    }
Aamir
  • 269
  • 4
  • 21