Solved

disable a datagrid linkbutton

Posted on 2009-07-08
3
423 Views
Last Modified: 2012-05-07
I am trying to disable my datgrid linkbuttons if they do not meet certain permissions.  I use this code to disable other stuff but for some reason if I do a false enable you can still click in the gray area and it completes the command.  How can I make it so that it makes the column invisible or the cell totally disabled.
<asp:TemplateColumn HeaderText="Archive">

<ItemTemplate>

<asp:LinkButton ID="lnkArchive" Runat="server" CommandName="Archive" CausesValidation="False">Archive</asp:LinkButton>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Delete">

<ItemTemplate>

<asp:LinkButton ID="lnkDelete" Runat="server" CommandName="Delete" CausesValidation="False">Delete</asp:LinkButton>

</ItemTemplate>

</asp:TemplateColumn>
 

Private Sub myDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles myDataGrid.ItemDataBound
 

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

            If checkAdmin() = False Then

                e.Item.Cells(6).Enabled = False

            End If
 

            If checkAdmin() = False Then

                e.Item.Cells(7).Enabled = False

            End If

        End If

    End Sub

Open in new window

0
Comment
Question by:kdeutsch
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 total points
ID: 24808121
try finding the control inside item like:

Dim lbtn1 As LinkButton = DirectCast(e.Item.FindControl("lnkArchive"), LinkButton)
Dim lbtn2 As LinkButton = DirectCast(e.Item.FindControl("lnkDelete"), LinkButton)

If checkAdmin() = False Then
                lbtn1.Enabled= False
                lbtn2.Enabled=false
End If
0
 

Author Comment

by:kdeutsch
ID: 24808381
Hi
Works great, i will post another question for my other problem with it.  It disabled it totally but it still brings up the javascript pop up box when I click in there.
0
 

Author Closing Comment

by:kdeutsch
ID: 31601306
Works great
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now