Hello,
I am trying to use gridview instead of listview.
Code:
<ItemTemplate>
<li>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' ToolTip='<%# Eval("ToolTip") %>' />
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
<asp:Button ID="DeleteButton" CommandName="Delete" runat="server" Text="Delete" /><br /><br />
</li>
</ItemTemplate>
As in the listview delete button is accessible through its ID "DeleteButton" like this
Code:
Dim deleteButton As Button = CType(e.Item.FindControl("DeleteButton"), Button)
Here I wanna use grid view and delete button for this I have used the commandField Delete in grid view but I can not access it as it does not provide any ID attribute.
Code:
<asp:CommandField ShowDeleteButton="true" />
So how I can access this delete button in grid view like this
Code:
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
Select Case e.Row.RowType
Case DataControlRowType.DataRow
Dim deleteButton As Button = CType(e.Row.FindControl("DeleteButton"), Button)
deleteButton.Visible = Roles.IsUserInRole("Manager")
End Select
End Sub
Thank you.