I have a gridview control where the last control is a hyperlink that allows someone to select that link and sign up for a class:

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" CellPadding="4" ForeColor="#333333"
        <RowStyle BackColor="#EFF3FB" />
            <asp:BoundField DataField="eventAuid" HeaderText="eventAuid" ReadOnly="True" SortExpression="eventAuid"
                InsertVisible="False" Visible="False" />
            <asp:BoundField DataField="eventOccurrencesAuid" HeaderText="eventOccurrencesAuid"
                SortExpression="eventOccurrencesAuid" InsertVisible="False" ReadOnly="True" Visible="False" />
            <asp:BoundField DataField="dayOfWeek" HeaderText="Day Of Week" SortExpression="dayOfWeek"
                ReadOnly="True" />
            <asp:BoundField DataField="startDateTime" HeaderText="Start Date/Time" SortExpression="startDateTime" />
            <asp:BoundField DataField="endDateTime" HeaderText="End Date/Time" SortExpression="endDateTime" />
            <asp:BoundField DataField="location" HeaderText="Location" 
                SortExpression="location" />
            <asp:BoundField DataField="remainingSpots" HeaderText="Remaining Spots" SortExpression="remainingSpots">
            <asp:HyperLinkField DataNavigateUrlFields="eventAuid,eventOccurrencesAuid" 
                Text="Sign up" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />

What I need to do is once the remaining spots in the gridview in each row is 0, then I need to change that hyperlink to Class Full and not allow anyone to click on it. Any ideas what I can do? I know that I would have to do it in the code behind which I would use C#, but I do not know how. Please help.


I'm throwing a bunch of assumptions into my theory here and without physically setting up a GridView that matches yours detail by detail I didn't get to test it but... This might work (and it wouldn't hurt to try unless someone else gives a better solution)

for (int a = 0; a < GridView1.Rows.Count; a++)
            if (GridView1.Rows[a].Cells[6].Text == "0")
                GridView1.Rows[a].Cells[7].Text = "Class Full";

Where Cells[6] should represent your remaining spots cell position if I counted right (starting at 0) and Cells[7] should represent your hyperlink cell position.

I hope it works :) If not, I hope someone else can be more helpful. Don't forget to mark solved once your issue has been resolved.

This worked perfectly, thanks again Lusiphur!!!