2009-11-24 7 views

Répondre

2

Disons que vous avez une colonne d'identité appelée IDTextBoxColumn. Vous pouvez obtenir la valeur pour chaque ligne comme ceci:

For Each row As DataGridViewRow In MyDataGridView.Rows 
    Console.WriteLine("ID value is " & row.Cells(IDTextBoxColumn.Index).Value.ToString()) 
Next 
1
Domain.Master.Product product = new Domain.Master.Product(); 
      foreach (DataGridViewRow dr in dataGridView1.Rows) 
      { 
       if (dr.Cells[0].Value == null) 
       { } 
       else 
       { 
        ProductViewModel pvm =roduct.ProductDetails(dr.Cells[0].Value.ToString()); 
        dr.Cells[3].Value = pvm.PCode.ToString(); 
        dr.Cells[4].Value = pvm.Pdtcatagory; 
       } 
      } 
Questions connexes