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 8215505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:48:36+00:00 2026-06-07T11:48:36+00:00

So I had have a table populating with data but I was wondering how

  • 0

So I had have a table populating with data but I was wondering how I could pass two bits of data from a row depending on which link at the end of the row is clicked.

<%WebReceiptSummary[] receipts = GetReceipts();
          if (receipts != null)
          {
              for (int i = 0; i < receipts.Length; i++)
              {%>
        <tr>
            <td><%= receipts[i].Type%></td>
            <td><%= receipts[i].PolicyNo%></td>
            <td><%= receipts[i].Date%></td>
            <td class="c"><%= receipts[i].Amount%></td>
            <td class="r"><asp:LinkButton OnCommand="PDFLinkClick" 
CommandArgument="<%= receipts[i].PDF %>&<% receipts[i].PolicyNo %>" runat="server">View PDF</asp:LinkButton></td>
        </tr>
        <% }
        }
        %>

Obviously my CommandArgument just passes back the string <%= receipts[i].PDF %>&<% receipts[i].PolicyNo %> not the values. What would be the best way of doing this? I was also thinking of using;

<asp:HiddenField ID="hiddenIsCaptchaReadyValidate" runat="server" Value=false/>

But I have the same problem here where the value is placed within quotes and also it means I need to create two hiddenfields for ever row which isn’t the most efficient way of doing this. Thoughts?

  • 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-06-07T11:48:38+00:00Added an answer on June 7, 2026 at 11:48 am

    It is not possible to have <%= %> commands as part of an attribute when added via the mark-up.

    Can I recommend that instead of using the for loop in the ASPX, you instead use the <asp:Repeater> control? This will also allow you to set the CommandAttribute value from the code-behind.

    An example…

    <asp:Repeater runat="server" id="receipts" OnItemDataBound="receipts_ItemDataBound">
      <ItemTemplate>
        <tr>
            <td><%#((WebReceiptSummary)Container.DataItem).Type%></td>
            <td><%#((WebReceiptSummary)Container.DataItem).PolicyNo%></td>
            <td><%#((WebReceiptSummary)Container.DataItem).Date%></td>
            <td class="c"><%#((WebReceiptSummary)Container.DataItem).Amount%></td>
            <td class="r"><asp:LinkButton ID="pdfLink" OnCommand="PDFLinkClick" runat="server">View PDF</asp:LinkButton></td>
        </tr>
      </ItemTemplate>
    </asp:Repeater>
    

    In your Init or Load in code behind…

    receipts.DataSource = GetReceipts();
    receipts.DataBind();
    

    Then…

    protected void receipts_ItemDataBound(Object sender, RepeaterItemEventArgs e)
    {
      ((LinkButton)e.Item.FindControl("pdfLink")).CommandArgument = 
        ((WebReceiptSummary)e.DataItem).PDF + ((WebReceiptSummary)e.DataItem).PolicyNo;
    }
    

    UPDATE

    Thinking about it, rather than using the code-behind setting of the CommandArgument, I think (I haven’t tested this yet) you could actually do the following without needing the receipts_ItemDataBound function…

     <td class="r"><asp:LinkButton ID="pdfLink" OnCommand="PDFLinkClick" runat="server"
       CommandArgument="<%#((WebReceiptSummary)Container.DataItem).PDF + ((WebReceiptSummary)Container.DataItem).PolicyNo%>"
       >View PDF</asp:LinkButton></td>
    

    UPDATE 2

    All instances of Container.DataItem in the above examples, have been changed into the tight-bound ((WebReceiptSummary)Container.DataItem)

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

Sidebar

Related Questions

I am using Microsoft SQL Server. I have a Table which had been updated
I have a table ('sales') in a MYSQL DB which should rightfully have had
We have a table that has had the same data inserted into it twice
I have a UITableView I'm populating with data from CoreData. I have a data
I have a table which maintains performance data of a system, each record is
I have had this problem w/ two seperate WYSWYG editors in my rails application
I have a table which has a couple cells that contain simple numbers (IE:
I am trying to write a SQL Server query but have had no luck
I know it is broad question but I am really confused. I have table
I have a table which has event-details. New records will be inserted to this

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.