簡體   English   中英

如何檢查gridview中的某個列是否有空行並能夠執行操作

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM