0

I would like to change the text on a particular table header in a Layout Template in a ListView programmatically (depending on the value in the database). It works but the styling is no longer using the LinkButton styling(green and clickable). Instead it's black and bold (not clickable)

I used the following (Access "th" in Listview):

My c#:

HtmlTableCell thCustCol = lstAuthorizations.FindControl("customColumn") as HtmlTableCell;
thCustCol.InnerText = query.Select(x => x.Custom1).First().ToString();

I also tried applying FindControl to "LinkButton10" instead, but then it had an (null reference)exception.

My aspx:

<LayoutTemplate>
    <div class="table-responsive">
        <table class="table">
            <thead>
                <tr>
                      <th runat="server" id="customColumn"><asp:LinkButton id="LinkButton10" runat="server" CommandArgument="Custom1" CommandName="Sort">Group ID</asp:LinkButton></th>

It looks like this:

Table Headers

The "1000" is a tableheader, but should be a green LinkButton like "Member Name"

What am I missing?

seesharp
  • 101
  • 1
  • 14

1 Answers1

0

Instead of setting the value to the ID of the LinkButton, I needed to associate the LinkButton to the th in the c# code and then set the value:

LinkButton lk = thCustCol.FindControl("LinkButton1") as LinkButton;
lk.Text = "link text";
seesharp
  • 101
  • 1
  • 14