Datarow

Résolu
romain60112 Messages postés 70 Date d'inscription mercredi 1 octobre 2008 Statut Membre Dernière intervention 17 avril 2013 - 19 juil. 2011 à 14:42
romain60112 Messages postés 70 Date d'inscription mercredi 1 octobre 2008 Statut Membre Dernière intervention 17 avril 2013 - 20 juil. 2011 à 11:05
Voilà j'ai un datarow où je souhaite y modifier un champ.
Mais comment faire ?

Voici un bout de mon code :

for (int i = 0; i < Profil.TableSortie.Rows.Count; i++)
{
foreach (DataRow Temp in Profil.TableSortie.Rows)
{

if (string.Compare(Global.sCurrentUserConnected, Temp["Pseudo"].ToString(), false) == 0)
{
Temp["Pseudo"] = textBoxNouveauPseudo;
}
}
}
Profil.TableSortie.AcceptChanges();
SaveSortie();

Si vous avez des idées n'hésitez pas.
Romain

2 réponses

NHenry Messages postés 15112 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 13 avril 2024 159
19 juil. 2011 à 21:59
Bonjour,

De tête, je crois qu'il faut que tu donne l'index de la case dans la ligne, pas son nom.

Mon site
3
romain60112 Messages postés 70 Date d'inscription mercredi 1 octobre 2008 Statut Membre Dernière intervention 17 avril 2013 1
20 juil. 2011 à 11:05
Merci beaucoup NHenry, ça tourne comme il faut !

Voilà une solution au cas où quelqu'un aurais besoin.

int indexSortie = Profil.TableSortie.Columns.IndexOf("Pseudo");
for (int i = 0; i < Profil.TableSortie.Rows.Count; i++)
{
foreach (DataRow Temp in Profil.TableSortie.Rows)
{
if (string.Compare(Global.sCurrentUserConnected, Temp["Pseudo"].ToString(), false) == 0)
{
Temp[indexSortie] = textBoxNouveauPseudo.Text;
}
}
}
3
Rejoignez-nous