Looping through rows in a DataView

前端 未结 4 1334
鱼传尺愫
鱼传尺愫 2020-12-09 07:30

The DataView object doesn\'t have a Rows property like DataTable.

How do I loop through the rows of a DataView?

4条回答
  •  一个人的身影
    2020-12-09 07:50

    I prefer to do it in a more direct fashion. It does not have the Rows but is still has the array of rows.

    tblCrm.DefaultView.RowFilter = "customertype = 'new'";
    
    qtytotal = 0;
    for (int i = 0; i < tblCrm.DefaultView.Count; i++)
    {
        result = double.TryParse(tblCrm.DefaultView[i]["qty"].ToString(), out num);
        if (result == false) num = 0;
        qtytotal = qtytotal + num;
    }
    
    labQty.Text = qtytotal.ToString();
    

提交回复
热议问题