【问题标题】:How to check if a certain column in gridview has an empty row and be able to perform an action如何检查gridview中的某一列是否有空行并能够执行操作
【发布时间】:2016-10-10 08:44:34
【问题描述】:

我有一个网格视图,其中包含 Action、Sigin Date 和 Signout date 列。 “操作栏”是按钮字段栏。对于注销日期列中的每个单元格,我希望启用注销日期的同一行中的按钮。如果有注销日期,我希望禁用该按钮。我该怎么做?

【问题讨论】:

标签: c# asp.net gridview


【解决方案1】:

在我的项目中使用之前的示例代码

   <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";
                    }

【讨论】:

  • 完美运行。感谢您的帮助
猜你喜欢
  • 2015-06-25
  • 2012-10-03
  • 2021-06-26
  • 1970-01-01
  • 1970-01-01
  • 2019-05-18
  • 2021-09-09
  • 2019-05-12
  • 2015-03-25
相关资源
最近更新 更多