`ASP.NET utilized for displaying several pictures on a website`

My goal is to retrieve images from a database and showcase them on a webpage. I am looking to incorporate a "show more images" button in case there are too many images to display at once. Additionally, I would like for the additional images to load automatically on the same webpage when the user clicks on the "show more" button using ASP.Net.

Answer №1

To display student details, you can utilize a repeater control:

<asp:Repeater ID="rptStudentDetails" runat="server">
    <HeaderTemplate>
        <table border="1" cellpadding="1">
            <tr style="background-color: #fa7b16; color: #FFF; height: 35px;" align="center">
                <th>
                    Student Name
                </th>
                <th>
                    Class
                </th>
                <th>
                    Age
                </th>
                <th>
                    Gender
                </th>
                <th>
                    Address
                </th>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr style="background-color: white;" align="center">
            <td>
                <%#Eval("StudentName") %>
            </td>
            <td>
                <%#Eval("Class") %>
            </td>
            <td>
                <%#Eval("Age") %>
            </td>
            <td>
                <%#Eval("Gender") %>
            </td>
            <td>
                <%#Eval("Address") %>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
<asp:Button ID="btnLoadMore" runat="server" Text="Load More Data" OnClick="btnLoadMore_Click" />

In the code-behind file (.cs)

protected void btnLoadMore_Click(object sender, EventArgs e)
{
    int numVal = Convert.ToInt32(ViewState["num"]) + 2;
    BindRepeater(numVal);
    ViewState["num"] = numVal;
}
private void BindRepeater(int numOfRows)
{
    DataTable dt = new DataTable();
    SqlCommand cmd = null;
    SqlDataAdapter adp = null;
    try
    {
        int rCount = rowCount();
        
        if (numOfRows > rCount)
        {
            btnLoadMore.Visible = false;
        }
        cmd = new SqlCommand("GetStudentDetails_SP", con);
        cmd.Parameters.AddWithValue("@topVal", numOfRows);
        cmd.CommandType = CommandType.StoredProcedure;
        adp = new SqlDataAdapter(cmd);
        adp.Fill(dt);

        if (dt.Rows.Count > 0)
        {
            rptStudentDetails.DataSource = dt;
            rptStudentDetails.DataBind();
        }
    }
}

For more information, visit the following links:

Asp.Net Load more data records on button click in Repeater Control from sql server table

LOAD MORE DATA RECORDS ON BUTTON CLICK IN ASP.NET REPEATER FROM SQL SERVER TABLE

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transferring information from a service to an AngularJS controller

I have a service that retrieves data from a URL provided as a parameter, and it is functioning correctly. However, when attempting to pass this data to a controller's $scope in AngularJS, I am not receiving any data. var app = angular.module("Recib ...

WebView no longer refreshes when the document location is updated

I currently have a basic HTML/JavaScript application (without Phonegap) that I utilize alongside a native Android app and a WebView. When certain situations arise, I need to reload the current page in the JavaScript portion. On my old phone with Android 4 ...

How can I execute route-specific middleware in advance of param middleware in Express v4?

Let me share a unique situation in my routing setup where I need to trigger a middleware before the parameter middleware is executed: router.param('foo', function (req, res, next, param) { // Accessing the param value ... next() }) router ...

The properties are not appearing on the screen nor in the React Development Tools

Having difficulties grasping React props and mapping data from an array? Struggling to get the props to show up on your Card component, or display in React dev tools? It's unclear where the mistake lies. Seeking assistance to pinpoint the issue. Also ...

Error: The property 'title' is not defined and cannot be read

Javascript - Node.js - Express - MongoDB - Mongoose In my code, I am using a forEach() method that iterates through each user and manipulates an array by adding or removing items. Strangely, the method successfully adds the correct number of items for one ...

What is the process for obtaining a direct link to a file that has been uploaded using a

Can Google Apps Script provide a direct link to a file that has been uploaded to a Google Drive folder? Currently, I can only obtain a link to the folder itself where all files are saved. This is the code I am using for file uploads: function processFor ...

The latest images are now visible in the table alongside the existing images that were previously added

When inserting images here, previously added images are displaying. Any solutions? Here is my view page <div class="col-md-2"> <form enctype="multipart/form-data" method="post" action="<?php echo base_url();?>admin_control/upl ...

Locate the position of an item in JavaScript based on its value

My json contains a lengthy list of timezones like the examples below. [ {"value": "Pacific/Niue", "name": "(GMT-11:00) Niue"}, {"value": "Pacific/Pago_Pago", "name": "(GMT-11:00) Pago Pago"}, {"value": "Pacific/Honolulu", "name": "(GMT-10:00) Hawaii T ...

Error: Issue transferring data to controller from Ng-Style

Currently, I am developing an application using Ionic and AngularJS. In this project, I am using ng-repeat to populate the results and want to display different colors based on certain criteria. Initially, I managed to achieve this using inline ng-style c ...

Implement inline-block along with center alignment in CSS

Is there a way to create a div that matches the width of its content using display: inline-block;, while still preserving the center alignment with text-align: center;? Currently, when I apply text-align: center, the content of the div shifts to the left a ...

Why is the console log not working on a library that has been imported into a different React component?

Within my 'some-library' project, I added a console.log("message from some library") statement in the 'some-component.js' file. However, when I import 'some-component' from 'some-library' after running uglifyjs with ...

Can you tell me about some commonly used GUI widgets in Servlet-JSP?

I am new to working with Servlets, Tomcat, JSP, and I am curious about the common practices for incorporating GUI elements into JSP pages to enhance client-side interactivity. I have experience with jQuery, YUI, extJS, among others, for JavaScript scriptin ...

Set up a listener to detect changes in fullscreen mode for the specified host

How can I determine if the fullscreen mode is active using the HTML5 fullscreen API with Chrome and Angular 4.x? I have developed an Angular component and included the following @HostListener: @HostListener('document:webkitfullscreenchange', ...

Ensure the footer remains fixed while scrolling

For the past day, I've been tackling a challenge with my online shop project. On the specific item's page, I want to include a fixed [add to cart] button as a footer initially, which then becomes sticky when scrolling to a certain point. You can ...

Angular: Dynamically changing checkbox's status from parent

I'm in the process of developing a switcher component that can be reused. The key requirement is that the state of the switch should only change after an API call is made at the parent component level. If the API call is successful, then the state cha ...

The min-width of 100vh is functioning properly on mobile devices, however, it is not working as expected on PCs when set to 100

When using 100vh, it only works on mobile or if you narrow the width of your web browser on a PC. If the window/width is set at 100%, the image may appear too tall and cause the div class "mars" to overflow the viewport. Unfortunately, screenshots cannot ...

Refresh the homepage utilizing a user control

My main page features a grid view displaying user data using the BindGrid method. Each row in the grid view has command buttons such as Update that perform specific operations. When a user clicks on the update button, a user control is shown to allow for u ...

The value from the angular UI bootstrap datepicker is unavailable when using a JQuery expression

I have a question regarding the datepicker feature from the Angular UI bootstrap library. The documentation can be found here. After selecting a date using the datepicker, I am facing an issue with retrieving the text input using jQuery expressions. When ...

recovering hidden components within an object

I've come across a data structure that contains embedded objects, presenting an interesting challenge: var object = { 'A' : {'cc' : { 'cc data 1' : 'data 1 cc for A', ...

Exploring data that is nested within its parent

I'm struggling to understand the concept of Nested selections or how to apply it to my specific situation. Here is an example of the JSON data format I am working with: { 'name': 'root' 'children': [ { &ap ...