We help IT Professionals succeed at work.

select first item in a gridview

JCWEBHOST
JCWEBHOST asked
on
Hey guys i need to get the first item in my gridview, which is a hyperlink and make the hyper link class to avtive.

here my aspx page:

 
<asp:GridView ID="GridView" runat="server" GridLines="None" ShowHeader="False" AutoGenerateColumns="False" HorizontalAlign="Center">
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <table cellpadding="0" cellspacing="0" style="width: 210px;">
                                                    <tr>
                                                        <td class="middle">
                                                            <asp:HyperLink ID="HyperLink" runat="server" ToolTip='<%# Bind("title") %>' Text='<%# Bind("short_title") %>' NavigateUrl='<%# Eval("id", "~/Projects.aspx?id={0}") %>'></asp:HyperLink>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

Open in new window


i need c# code please...

i am binding my gridview with c# code.
Comment
Watch Question

Project Lead
Top Expert 2011
Commented:
You can get it like this

HyperLink link = (HyperLink) GridView.Rows[0].FindControl("HyperLink");