View Single Post
  #1 (permalink)  
Old March 8th, 2012, 02:25 PM
markmanxp markmanxp is offline
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 15 - Hide Delete Button

Love the book! Can't believe how much I have learned!

I followed the process outlined on page 546 for hiding a delete button in the gridview - works great. I'm trying to expand on this functionality by applying this same idea when using the ListView control. I see later on page 615 you have accomplished this with a ListView control but use Roles to determine the visiblity of the button. I don't want to use the Roles in my case I just want the same functionality used here - (but using a listview)

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
switch (e.Row.RowType)
case DataControlRowType.DataRow:
DataRowView myDataRowView = (DataRowView)e.Row.DataItem;
if (Convert.ToInt32(myDataRowView[“NumberOfReviews”]) > 0)
LinkButton deleteLink = e.Row.FindControl(“DeleteLink”) as LinkButton;
if (deleteLink != null)
deleteLink.Enabled = false;
I've gotten this far BUT then don't know how to proceed

switch (e.Item.ItemType)
            case ListViewItemType.DataItem:
           ListViewItem myItem = (ListViewItem)e.Item.DataItem;
Reply With Quote