ASP.NET: Clickable BoundField in Gridview

Problem: I customized my gridview and created a set of boundfield columns. Now, I need to make one of these boundfields be clickable or some sort of hyperlink.

Solution: Create a TemplateField and a hyperlink control in your ItemTemplate.

<asp:GridView ID="GridView1" runat="server">
   <Columns>
      <asp:TemplateField>
         <ItemTemplate>
            <asp:HyperLink ID="Hyperlink1" runat="server"
               Text='<%# Bind("FieldName") %>'>
            </asp:HyperLink>
         </ItemTemplate>
      </asp:TemplateField>

In this example, the HyperLink Text property is binded to a specific field from the datasource used by the gridview. In this way you could now have a clickable BoundField in your gridview. Just modify the NavigateUrl property of the HyperLink control for its navigation functionality.

4 Responses to “ASP.NET: Clickable BoundField in Gridview”


  1. 1 bleue

    Woooh! Pre, I Installed VS 2005 at home for self study. Will ask you if I have questions .net master! hehehe! XD

  2. 2 rs

    wehehe, wag ka maingay bleue nagpapanggap lang akong may alam!

  3. 3 jan

    parekoy, di ko alam ano gagawin ko pagwala ka. pano ung header neto nawala? pano ko lalagyan ng header ung field? paglagay ko ng template mo sa isang column ung column header nya nawala.

    sakit sa ulo asp.net ah pagdating sa customization whew!!

  4. 4 jan

    tsaka pala pano ung autoformat ng gridview hindi gumagana sa IE 8 ko pero firefox ok..

Leave a Reply