disable link in gridview

I have a link in a gridview that when clicked brings up another page with detailed information about the record.  However, there are certain records in the gridview that do not have detailed information, this is when I'd like to disable the 'View Details' hyperlink.  How can this be accomplished?  Here is my attempt, but of course is not working:

If GridView1.Rows.Item(4).ToString = "A" Then

            GridView1.Columns.Item(0).Visible = False
            GridView1.Columns.Item(1).Visible = False
LVL 4
newbiealAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

newbiealAuthor Commented:
This is not working for me.  I tried the VB example.

I get this error:

A is neither a DataColumn nor a DataRelation for table DefaultView.

When implementing this code:


 <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("A_ID", "test3.aspx?A_ID={0}") %>'
                            Text="View A"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>


 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim drv As System.Data.DataRowView = DirectCast(e.Row.DataItem, Data.DataRowView)
            Dim a As HyperLink = DirectCast(e.Row.FindControl("View A"), HyperLink)
            If drv("A") Then
                a.Visible = False
            Else
               a.Visible = True
            End If
        End If

    End Sub
0
safitechCommented:
Are you trying to read a value from a control in the GridView or from the underlying data source?

If you're reading a control value, say a label, you could use more or less the same code you already have (sub in your control name):

         If e.Row.RowType = DataControlRowType.DataRow Then
            Dim drv As System.Data.DataRowView = DirectCast(e.Row.DataItem, Data.DataRowView)
            Dim a As HyperLink = DirectCast(e.Row.FindControl("View A"), HyperLink)
            Dim testControl As Label = DirectCast(e.Row.FindControl("LabelName"), Label)
            If testControl.Text = "A" Then
                a.Visible = False
            Else
               a.Visible = True
            End If
        End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbiealAuthor Commented:
Once of the columns is named colum A and the data displayed in it could be, A, B, or C.  I want to test for one of these values.  If A, then disable hyperlink.  I believe the example you gave won't work with this?
0
safitechCommented:
Like I say, that should work if you're displaying the value of that column in a Label, but maybe that's not what you're doing.  

Perhaps you could clarify the question by showing the GridView and DataSource declarations.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.