0

SetVisibility 检查数据库是否应该启用所有按钮。我想禁用所有按钮if setvisility(UserID) == false

这部分代码只禁用交替的向上和向下按钮。有人可以建议为什么会这样吗?

else
{
    Button b = e.Item.FindControl("btnmoveup") as Button;
    b.Enabled = false;
    Button b2 = e.Item.FindControl("btnmovedown") as Button;
    b2.Enabled = false;
}

这是完整的代码:

if (e.Item.ItemType == ListItemType.Item)
{
    String userID = User.Identity.Name.Split('\\')[1];
    if (setvisibility(userID) == true)
    {
        if (e.Item.ItemIndex == 0)
        {
            Button b = e.Item.FindControl("btnmoveup") as Button;
            b.Enabled = false;
        }

        DataView view = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        DataTable result = view.ToTable();
        if (e.Item.ItemIndex == (result.Rows.Count) - 1)
        {
            Button b2 = e.Item.FindControl("btnmovedown") as Button;
            b2.Enabled = false;
        }
    }
    else // How to disable all the buttons ? 
    {
        Button b = e.Item.FindControl("btnmoveup") as Button;
        b.Enabled = false;
        Button b2 = e.Item.FindControl("btnmovedown") as Button;
        b2.Enabled = false;
    }
}
4

1 回答 1

3

采用:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
于 2012-06-27T13:40:13.333 回答