How to add link button in grid view in asp.net

{0 Comments}

If you want to add a link button in grid view (which can be used like navigation link to next form) but you actually don’t know how to insert that link button into grid view column. Then here an article to sort your problem

For this major requirement is to add a template column in your grid view, you can do this by both design view or with source view in visual studio.  

In source view you can use following code snippets.

 HTML |  copy code |? 
1
<asp:TemplateField>
2
  <ItemTemplate>
3
    <asp:LinkButton ID="Lnkbtn" runat="server" >Your_text</asp:LinkButton>
4
  </ItemTemplate>
5
</asp:TemplateField>

And after adding above script check following things must be done with that, these are:

  • Make sure grid view data source is bounded.
  • Set auto Generate column to false.
  • Open grid view task, and add hyperlink in new column.

Now using design view follow these steps

  • Using edit column option from the context menu and clicking smart tag and add template field
  • Add template field in selected field list.
  • Right click on grid view
  • Select edit template
  • Now drag-drop link button control from the tool menu to the grid.
  • Bind the property of link column field using data binding.

These steps will help you to add a link button in grid view and any thing you want to…  

 HTML |  copy code |? 
1
2

Leave a Comment

Your email address will not be published.