Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 July 31st, 2007, 03:08 PM
Friend of Wrox
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to hide linkbutton in edit mode of a gridview


i want to perform several things (like checking and correcting automatically the lenght of a multiline textbox in order to avoid Truncate error, removing automatically "<" and "'" to avoid "potential danger" error etc ..) with javascript on a gridview.

If i take in the aspx file this:
<asp:CommandField ShowEditButton="True">
i have no possibility to use the OnClientClick property.

So i made some Templatefields like this:
<asp:LinkButton ID="lb1" runat="server" CommandName="Edit"

<asp:LinkButton ID="lb2" runat="server" CommandName="Update"

<asp:LinkButton ID="lb3" runat="server" CommandName="Cancel"

My problem is now that the linkbutton "Edit" not only appears in normal
mode, but also in Edit mode, together with "Update" and "Cancel". I don't understand why, but now i want to get rid of it.

I did this in code-behind:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If (e.Row.RowState And DataControlRowState.Edit) = DataControlRowState.Edit Then
            Dim lb As LinkButton
            lb = e.Row.FindControl("lb1")
            lb.Visible = False
        End If
    End Sub

Now the linkbutton is invisible but only for the selected row and there is still an empty
space in the gridview.

Any way to solve this?

Similar Threads
Thread Thread Starter Forum Replies Last Post
gettting data from gridview in edit mode text cont mahboob_sabir ASP.NET 2.0 Professional 1 May 8th, 2007 02:05 AM
Datagrid - edit mode Programator ASP.NET 1.0 and 1.1 Professional 1 September 5th, 2003 08:38 AM
Datagrid - edit mode Programator ASP.NET 1.x and 2.0 Application Design 1 September 5th, 2003 08:37 AM
Datagrid - edit mode Programator Classic ASP Professional 0 September 5th, 2003 03:13 AM

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