Solved

disable a datagrid linkbutton

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery datatables, asp.net MVC 9 41
Alert on Server memory 2 22
Footer for each row on Gridview 2 21
VB.net and sql server 4 36
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:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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