Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2010, 10:39 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default Grid view and delete button

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") %>' />&nbsp;
<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.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
 
Old May 11th, 2010, 04:49 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

On the Edit Fields / Columns dialog of the GridView you can tranform the column into a template column which then gives you access to the button.

Since this isn't directly related to the book, can you ask these kind of questions in a more general ASP.NET category here: http://p2p.wrox.com/asp-net-3-5-436/

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 13th, 2010, 07:00 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Hi Imar,
Thanks it will really help me.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com





Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
Help Grid View Drop Down List, view all jskinner123 ASP.NET 2.0 Basics 0 November 25th, 2007 06:25 PM
grid view komalpriya .NET Framework 2.0 3 November 7th, 2007 10:34 AM
radio button in grid view MunishBhatia ASP.NET 2.0 Professional 8 August 8th, 2007 04:47 AM
grid view MunishBhatia ASP.NET 2.0 Professional 2 June 5th, 2007 12:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.