473,654 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

repeated data managment on listview control

Greetings
I have a problem using listview control. Well, I belive that this is not
realy a problem, but it's consuming me precious time.

Here is the scenario (an example of my problem).

I have a SqlServer CE table named students that has 2 fields: students
name and grade.

I want to populate the a listview with all the students stored on my table.
(A simple select * from table sql statement). Simple so far... But
things get complicated because the name of the students are composed by
the first name and last name. So it can be the same names but regarding
different students! OK. In addition, the table has as primary key an
integer record named ID "auto incremented". This is what stays different
for all the records on table.

When I populate the listview, it displays on name column repeated data,
that in fact corresponds to different students.

My problem is when I have to edit or delete a record on database.

My listview has 2 columns - Name and Grade. When I populate the listview
I do something like this.

for(int i=0;i<theStuden tsArray;i++)
{
StudentObj theStudentAux=t heStudentsArray[i];
// each instance of StudentObj class has the
// properties Name, Grade and ID
string[] str=new string[2];

str[0]=theStudentAux. Name.ToString() ;
str[1]=theStudentAux. Grade.ToString( );

ListViewItem lItem=new ListViewItem(st r);

lViewStudents.I tems.Add(lItem) ;
}

this is my code, but I'm not able to "put" the ID property (because I do
not want to show it on listview!) together with the ListViewItem. So,
when I want to delete or update a student with the name of Foo XPTO
(and, say, there are three Foo XPTOs on my list) I don't know what is
the one to update/delete on database! What I need is, when I select an
item of listview, to be able to get the database ID that corresponds to
that item. If ListViewItem have a Tag attribute the problem was solved.
But it does not contais the Tag attribute.

So what are your opinions for this problem?
Once far away time I've read an article regarthing this problem, but at
the time I did not pay much attention, and know I can't find it on the
web... :(

Can anyone give a hint?

TIA
Almeida
Nov 16 '05 #1
0 1418

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1443
by: JamesB | last post by:
Hello I have a form which contains a Listview control that is filled with data as the program runs. This all works fine, but I want to also then do a certain process on this data at the same time. Because of the way the data is received into the control (from an event out of my hands) my processing causes problems as it is time-intensive. So, I figure my processing should go in a separate thread so it can work without stopping the...
3
2107
by: MikeY | last post by:
Hi everyone, I'm having problems, or should I say still having problems with trying to pass data from my custom buttons in my custom controls to my main form listview box. Still scratching my head and had a sleepless night trying to figure this one out. So hopefully someone can help. I have a user control named Ctr_Horizontal_Btn.cs (houses my custom buttons) namespace = HOST_Horizontal_Btn. A public class named =...
1
1860
by: Alec MacLean | last post by:
Hi, Outline of problem: I've built a set of user controls that are used to output questions for a survey and gather the responses using simple radio buttons. I'm adding an optional textbox to the question control to allow individual typed responses per question. I've got a maximum length to enforce which matches the underlying data table design.
3
1632
by: cr113 | last post by:
I'm trying to convert a windows app to ASP.NET using VS2005. I have some web experience, but not much. 99% of the time if I need to display data in a table in my windows apps I use a ListView object and populate it manually using code like this: ListView1.Items.Add("Jones") ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("123") The result of this code would be a row added to the ListView like this:
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.