473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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<theStudentsArray;i++)
{
StudentObj theStudentAux=theStudentsArray[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(str);

lViewStudents.Items.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 1407

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

Similar topics

3
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...
3
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...
1
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.