Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I assuming the grid you are referring to is a data grid? </p> <p><a href="http://www.codeproject.com/KB/webforms/datarepeater_in_datagrid.aspx" rel="nofollow noreferrer">This tutorial</a> has a great example. To summarise:</p> <p>Add a Template column to your grid view in place of the link button column:</p> <pre><code>&lt;asp:datagrid id="dataGrid1" runat="server" Width="792px" AutoGenerateColumns="False" CellPadding="0" &gt; &lt;Columns&gt; &lt;asp:BoundColumn DataField="id" HeaderText="ID"&gt; &lt;HeaderStyle Width="190px" HorizontalAlign="Center" &gt; &lt;/HeaderStyle&gt; &lt;/asp:BoundColumn&gt; &lt;asp:TemplateColumn HeaderText="Tags" HeaderStyle-HorizontalAlign="Center"&gt; &lt;ItemStyle HorizontalAlign="Left" Wrap="True"&gt;&lt;/ItemStyle&gt; &lt;ItemTemplate&gt; &lt;asp:Repeater ID="rptChild" runat="server" DataSource='&lt;%# DataBinder.Eval(Container.DataItem, "tags").ToString().Split(tagSplitChars) %&gt;'&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="linkChild" runat="server" CommandArgument="&lt;%# Container.DataItem%&gt;" &gt; &lt;%# Container.DataItem%&gt; &lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateColumn&gt; &lt;/Columns&gt; &lt;PagerStyle PageButtonCount="20" Mode="NumericPages"&gt;&lt;/PagerStyle&gt; &lt;/asp:datagrid&gt; </code></pre> <p>Note that tagSplitChars should be defined in your code behind as:</p> <pre><code> protected char[] tagSplitChars = new char[] { ' '}; </code></pre> <p>Clearly you can add an "onclick" handler to you link button as you need.</p> <p>I have tested this with this code behind and it works perfectly:</p> <pre><code>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&lt;dynamic&gt;() { new { id = 1, names = "one single" }, new { id = 2, names = "two double" } }; dataGrid1.DataBind(); } } } </code></pre> <hr> <p><strong>UPDATE</strong></p> <p>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:</p> <pre><code>&lt;asp:Repeater ID="rptChild" runat="server" &gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="linkChild" runat="server"&gt; &lt;%# Container.DataItem%&gt; &lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Then in the code behind</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { dataGrid1.DataSource = myTagsString.split(splitChars); dataGrid1.DataBind(); } </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload