Last post May 08, 2018 01:47 AM by Brando ZWZ
May 04, 2018 02:09 PM|D4NieL7|LINK
In my website, I am showing pictures, comments and albums in a way that when an album is clicked, you can see images and comments (using DataList for all albums, pictures and comments).
I am trying to show X button if you`re a manager so you can delete albums, images and comments easily using the Page_PreRender function.
problem is, I can only show X for images and comments (not albums). Maybe that is because you need to click a button to show them...
This is my C# code:
protected void Page_PreRender(object sender, EventArgs e)
localhost.WebService ws = new localhost.WebService();
DataTable albums = ws.getAlbums();
if (Session["loggedIn"] != null)
if ((string)Session["name"] == "shimritArc")
foreach (DataListItem item in DataList1.Items)
ImageButton btnDelAlbum = item.FindControl("ibDeleteAlbum") as ImageButton;
foreach (DataListItem item in dlShowComments.Items)
ImageButton btnDelComment = item.FindControl("btnDeleteComment") as ImageButton;
foreach (DataListItem item in DataList2.Items)
ImageButton btnDelImage = item.FindControl("ibDeleteImage") as ImageButton;
DataList1.DataSource = albums;
Please let me know if you need the HTML code (It`s just very very large and I`m 99% sure it`s fine)
May 08, 2018 01:47 AM|Brando ZWZ|LINK
According to your codes, I couldn’t directly find the reason why the btnDelAlbum image button doesn’t show in your codes.
I suggest you could post the details codes about your codebehind the DataListItem page codes.
Besides, I suggest you could add the breakpoint to the “Data1List1.Items” to check DataList1 have the datasource.
If you could post more detail codes, it will be more easily for us to reproduce the issue and find the solution.