Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 979361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:12:28+00:00 2026-05-16T04:12:28+00:00

I’ve an item template inside a grid which has a <asp:LinkButton/> inside it. I

  • 0

I’ve an item template inside a grid which has a <asp:LinkButton/> inside it. I assign the text for the link button as

<%# Convert.ToString(Eval("Tags"))%>

Tags can have a string with multiple tags in it delimited by space. For eg. “sports”, “sports cricket”, “sports cricket sachin” are the examples of some possible tags.

I want to create a button for each tag inside the string. How can i create the controls (server control – linkbutton) dynamically during runtime inside the grid item template?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:12:29+00:00Added an answer on May 16, 2026 at 4:12 am

    I assuming the grid you are referring to is a data grid?

    This tutorial has a great example. To summarise:

    Add a Template column to your grid view in place of the link button column:

    <asp:datagrid id="dataGrid1" runat="server" Width="792px" 
    
        AutoGenerateColumns="False" 
        CellPadding="0" >
    
        <Columns>
    
    
            <asp:BoundColumn DataField="id" HeaderText="ID"> 
                <HeaderStyle Width="190px" HorizontalAlign="Center" >
                </HeaderStyle> 
            </asp:BoundColumn> 
    
    
            <asp:TemplateColumn HeaderText="Tags" 
                         HeaderStyle-HorizontalAlign="Center"> 
                <ItemStyle HorizontalAlign="Left" Wrap="True"></ItemStyle> 
                <ItemTemplate> 
                    <asp:Repeater ID="rptChild" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem, "tags").ToString().Split(tagSplitChars) %>'> 
                        <ItemTemplate> 
                            <asp:LinkButton ID="linkChild" 
                            runat="server" 
                                CommandArgument="<%# Container.DataItem%>"
                                > 
                                <%# Container.DataItem%> 
                            </asp:LinkButton> 
                        </ItemTemplate> 
                    </asp:Repeater> 
                </ItemTemplate> 
            </asp:TemplateColumn> 
        </Columns> 
        <PagerStyle PageButtonCount="20" Mode="NumericPages"></PagerStyle> 
    </asp:datagrid>
    

    Note that tagSplitChars should be defined in your code behind as:

     protected char[] tagSplitChars  = new char[] { ' '};
    

    Clearly you can add an “onclick” handler to you link button as you need.

    I have tested this with this code behind and it works perfectly:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace Demo
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            public char[] splitChars = new char[] { ' '};
            protected void Page_Load(object sender, EventArgs e)
            {
                dataGrid1.DataSource = new List<dynamic>() { new { id = 1, names = "one single" }, new { id = 2, names = "two double" } };
                dataGrid1.DataBind();
            }
    
        }
    }
    

    UPDATE

    If you are just trying to add a list of buttons, and have no other columns to display in your grid, you can simplify the solution significantly:

    <asp:Repeater ID="rptChild" runat="server" > 
        <ItemTemplate> 
            <asp:LinkButton ID="linkChild" runat="server"> 
                 <%# Container.DataItem%> 
            </asp:LinkButton> 
        </ItemTemplate> 
    </asp:Repeater> 
    

    Then in the code behind

            protected void Page_Load(object sender, EventArgs e)
            {
                dataGrid1.DataSource = myTagsString.split(splitChars);
                dataGrid1.DataBind();
            }
    

    Clearly you will have to access the data in your datatable manually to extract the string, haven’t done this in a while but from memory it is quite simple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 485k
  • Answers 485k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since every of the four borders can have a different… May 16, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer You can use MSI api functions to enumerate all installed… May 16, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer Hard to tell with such a small snippet. In the… May 16, 2026 at 7:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.