?
Solved

disable a datagrid linkbutton

Posted on 2009-07-08
3
Medium Priority
?
438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 1000 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

Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

743 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