Make one Gridview field a selection link?

In ASP.NET 3.5, you can assign a Select link and change the display of the link. But can you assign one of the fields in the gridview to act as a selection button?

For example, all my records have a SAMPLE NAME field. It would be great if each unique SAMPLE identifier is a link that refers to the presentation of details. I cannot find any parameter under the gridview edit columns that appear to assign this behavior to a specific field.

I know this should be possible because I rarely see ASP.NET sites that actually use the Select link on the side - most of them let you click one of the fields.

How can i do this?

Using Visual Studio 2008, ASP.NET 3.5, and C # 3.0!

+3
source share
2 answers

I would add a ButtonField with a DataTextField as the column of the database table to which you want to bind it, and make the SelectName CommandName. I just did it in Visual Web Developer 2008 Express on a GridView and it worked. Good luck

+8
source

You can use the template field and bind LinkButton to the "SAMPLE ID". I don't have VS to check this out - but you have to start ...

<asp:TemplateField HeaderText="Sample Id">
    <ItemTemplate>
        <asp:LinkButton runat="server" CommandName="Select" Text='<%#Bind("SAMPLE ID")#>'></asp:LinkButton>
    </ItemTemplate>
</asp:TemplateField>
+1
source

Source: https://habr.com/ru/post/1712246/


All Articles