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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:26:39+00:00 2026-06-17T13:26:39+00:00

I want to loop through some data on a device application. For example: Select

  • 0

I want to loop through some data on a device application. For example:

Select name, surname, mail_ad, phone_nr from cust_details

On the form I want to display row by row with next and previous button. For example:

Name: Werner

Surename: VDH

Mail: werner@me.com

Phone number: 0716848805

[Previous] [Next]

I’ve been having a lot of trouble with this. I have used List before but it doesnt work like i want it to work. Can someone please help me here.

How i’ve been using List:

public List<String> InfoList = new List<String>();
int i = 1;

conn.Open();
string query;
query = "Select name, surname, mail_ad, phone_nr from cust_details";
OracleCommand cmd = new OracleCommand(query, conn);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
   this.InfoList.Add(dr["name"].ToString());
   this.InfoList.Add(dr["surname"].ToString());
   this.InfoList.Add(dr["mail_ad"].ToString());
   this.InfoList.Add(dr["phone_nr "].ToString());
}
dr.Close();
conn.Close();

and then in Next and previous buttons:

if (i + 1 < this.InfoList.Count)
   label1.Text = this.InfoList[++i];
if (i + 1 < this.InfoList.Count)
   label2.Text = this.InfoList[++i];
if (i + 1 < this.InfoList.Count)
   label3.Text = this.InfoList[++i];
if (i + 1 < this.InfoList.Count)
    label4.Text = this.InfoList[++i];


if (i - 1 < this.InfoList.Count)
   label1.Text = this.InfoList[--i];
if (i - 1 < this.InfoList.Count)
   label2.Text = this.InfoList[--i];
if (i - 1 < this.InfoList.Count)
   label3.Text = this.InfoList[--i];
if (i - 1 < this.InfoList.Count)
   label4.Text = this.InfoList[--i];

I’m using labels to display the data in. Problems I have:
Sometimes the order of the labels will get mixed up when I hit next.
or 1 label will not have any info in it.
when I hit previous and there is no more detail left I get exceptions.

  • 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-17T13:26:40+00:00Added an answer on June 17, 2026 at 1:26 pm

    I don’t know if this is what your looking for, but simply create a class and then use a List<YourClass>.
    Define it by using List<YourClass> myList = new List<YourClass>();

    To add values to the List you have to create an object of YourClass and define the values there:

    YourClass myClassObject = new YourClass();
    
    myClassObject.name = dr[i].toString(); //This is the database reader 
    

    Class YourClass contains the following properties:

    string name, 
    string surname, 
    string mail_address, 
    string phone_nr.
    

    Properties are written like this and behave like global variables:

    internal string mystring {get; set;}
    

    Then you can loop through this list and use the variables with:

    name_Lbl.Text = this.myList.name[i]; //This is an example.
    

    Then use the OnPress-Event of the buttons to increment or decrement i.

    Edit: Name your classes properly 😉

    Edit 2: For more info about properties CLICK ME

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

Sidebar

Related Questions

I want to loop through some data I'm getting from a query using a
I have an application I'm working on where I want to loop through some
Pointer related question. I'm going through some example code that currently reads in data
I want to send some data to an Arduino through pyserial in Python. All
hi i want to loop through some tr's like this . <tr> <td> <input
I have an array of data containing some domains with TLD extensions. I want
I've got a xml that I'm parsing and trying to extract some data from.
I want to loop multiple times through my query results, and I have 2
I do have two text files and want to loop through both files then
I want to load an array with 1million guids, then loop through them and

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.