Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HowTo: From DataGridView control to ListBox
Message
De
27/03/2007 18:08:56
John Baird
Coatesville, Pennsylvanie, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01208957
Message ID:
01209041
Vues:
24
Okay, I thought you were familiary with the workings of ADO datasets. What you need to do is this.

There's a couple of ways to do this:
The easiest to understand:
//this is like a slect statement in sql
DataRow[] dra = dtSession.Select("PatientId = " + SelectedPatientId.ToString());

//loop through the array and populate the listview.
if(dra != null && dra.Length > 0)
{
   if (this.lstSession.Items.Count > 0)
   {
       this.lstSession.Items.Clear();
   }

   foreach (DataRow dr in dra)
   { 
      ListViewItem lvi = new ListViewItem(dr["Date"].ToString());
      this.lstSession.Items.Add(lvi);
   }
   
   this.lstSession.Refresh();
}
You can also use the filter capability of the defaultDataView to accomplish pretty much the same thing. The approach above should work well for you.

>John,
>
>Again thanks for your quick reply.
>
>If I understand your code correctly, this would put all of the dates from the SESSIONS table into the ListBox. But, I only want the dates for the patient that was selected in the grid by the user. Remember, there is a one-to-many relation between the Patients table and the Sessions table. The PatientID is the relation. I only want those dates for the case where Sessions.PatientID = SelectedPatientID
>
>Jim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform