[英]How to check if a certain column in gridview has an empty row and be able to perform an action
我有一個 gridview,其中包含 Action、Signin Date 和 Signout date 列。 “操作欄”是一個按鈕字段欄。 對於注銷日期列中的每個單元格,我希望啟用與注銷日期位於同一行的按鈕。 如果有退出日期,我希望該按鈕被禁用。 我該怎么做呢?
在我的項目中使用之前的示例代碼
<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";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.