Solved

disable a datagrid linkbutton

Posted on 2009-07-08
3
427 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 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