Solved

disable a datagrid linkbutton

Posted on 2009-07-08
3
422 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

11 Experts available now in Live!

Get 1:1 Help Now