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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:38:05+00:00 2026-06-09T14:38:05+00:00

In an asp.net application, I have the follow code in the aspx page: <asp:Content

  • 0

In an asp.net application, I have the follow code in the aspx page:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <% foreach (var questionPaper in QuestionPapers) { %>
    <div style="border-bottom: 1px solid; padding-bottom:20px">
        <%= questionPaper.University %><br/>
        <%= questionPaper.CourseName %>: <%= questionPaper.CourseCode %><br/>
        <%= questionPaper.Type %><br/>
        <%= questionPaper.Year %><br/>
        <asp:Button ID="View_Paper" runat="server" OnClick="ViewPaper" Text="View Paper"/>
    </div>
   <% } %>
</asp:Content>

I want to pass questionPaper.ID back to the ViewPaper() event handler on the server side, how do I do that?

    public void ViewPaper(object sender, EventArgs e)
    {

    }
  • 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-09T14:38:06+00:00Added an answer on June 9, 2026 at 2:38 pm

    My recommendation is to use a Repeater or a ListView control

    • Use a Repeater if the data will be used as read-only

    • Use a ListView if you want to page your results and/or allow the end user to perform CRUD operation over your data

    For example, your code would look like this when using a Repeater and an ObjectDataSource controls:

    ASPX

    <asp:ObjectDataSource ID="ods" runat="server" 
        SelectMethod="GetQuestionPapers" 
        TypeName="Your_Namespace.PapersRepository">
    </asp:ObjectDataSource>
    <asp:Repeater runat="server" DataSourceID="ods" ID="r" OnItemCommand="r_ItemCommand">
        <ItemTemplate>
            <div style="border-bottom: 1px solid; padding-bottom:20px">
                <asp:HiddenField runat="server" ID="paperID" Value='<%# Eval("PaperID") %>'/>
    
                <asp:Label runat="server" ID="university" Text='<%# Eval("University") %>'/><br />
                <asp:Label runat="server" ID="courseName" Text='<%# Eval("CourseName") %>'/>:<asp:Label runat="server" ID="courseCode " Text='<%# Eval("CourseCode ") %>'/><br />
                <asp:Label runat="server" ID="paperType" Text='<%# Eval("Type") %>' /><br />
                <asp:Label runat="server" ID="year" Text='<%# Eval("Year") %>' /><br />
                <asp:Button ID="View_Paper" runat="server" Text="View Paper" CommandName="ViewPaperCommand"
                />
            </div>
        </ItemTemplate>
        <SeparatorTemplate>
            <hr />
        </SeparatorTemplate>
    </asp:Repeater>
    

    ASPX code behind

    protected void r_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "ViewPaperCommand":
                var hidden = e.Item.FindControl("paperID") as HiddenField;
                var myPaperID = hidden.Value;
    
                break;
        }
    }
    

    Papers repository class

    namespace Your_Namespace 
    {
        public class PapersRepository 
        {
            public IEnumerable < QuestionPaper > GetQuestionPapers() 
            {
                return QuestionPapers.AsEnumerable();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a ASP.NET application (MVC) I have a foreach loop that loops through a
I have a jQuery accordion in a page in ASP:Net MVC application in which
My web application is an Asp.Net MVC pattern. None of the .aspx pages have
I have a ASP.Net Web Application which connects to a SQL Server. The web.config
I have an ASP.NET MVC3 application, where I use Entity Framework 4.3 Code-First and
In our Asp.Net Application we have an IHttpHandler handling requests for Images. The Handler
In my ASP.NET application I have separate projects for the Data, Business and UI
My SSRS report fetches data from my DATAWAREHOUSE. The ASP.NET application I have is
In my ASP .NET MVC application i have a link that refreshes the preview
I have an ASP.NET application where i have more than 100 pages.In each pages

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.