The SetVisibility checks against a database if all the buttons should be enabled or not. I want to disable all buttons if setvisility(UserID) == false
This part of the Code disables only alternating up and down buttons. Can someone please suggest why is this happening ?
else { Button b = e.Item.FindControl("btnmoveup") as Button; b.Enabled = false; Button b2 = e.Item.FindControl("btnmovedown") as Button; b2.Enabled = false; } Here is the Complete Code:
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; } }
Item.HasControlsbeItem.FindControl?