C Sharp方法条件
问题描述:
这个Param()方法这个条件意味着什么 if(DVLocal.Count> 0)
Tn this Param() method what this condition means if(DVLocal.Count > 0)
private string Param()
{
for (int i = 0; i < grdViewMachinaryDetailsApproval.Rows.Count; i++)
{
CheckBox cb = (CheckBox)grdViewMachinaryDetailsApproval.Rows[i].Cells[2].FindControl("chkSelect");
if (cb != null)
{
if (cb.Checked)
{
ConManager.DBConnection("TERMSHR");
ConManager.BeginTransaction();
DTLocal = new DataTable();
DVLocal = new DataView();
strSQL = "select * from tblMachinaryDetails where MDCode = '" + grdViewMachinaryDetailsApproval.Rows[i].Cells[3].Text.ToString() + "'";
ConManager.OpenDataTableThroughAdapter(strSQL, out DTLocal, true);
DTLocal.TableName = "MachinaryDetails";
DVLocal.Table = DTLocal;
if (DVLocal.Count > 0)
{
DRLocal = DVLocal[0].Row;
DRLocal.BeginEdit();
DRLocal["StateStatus"] = ddlAction.SelectedValue.Trim();
DRLocal["ApprovedDate"] = System.DateTime.Now.ToString();
DRLocal.EndEdit();
}
ConManager.SaveDataTableThroughAdapter(ref DTLocal, true);
}
}
}
return strParam;
}
答
DVLocal是一个数据视图,因此更容易找到的方法是使用Google: GoogleDataView.Count [ ^ ] - 第一个命中是指向MSDN的链接: MSDN:DataView.Count Property [ ^ ]告诉你所有相关信息。
说的是它返回应用RowFilter和RowStateFilter后DataView中的记录数。
所以行:
DVLocal is a Dataview, so the easier way to find out is to use Google: Google "DataView.Count"[^] - the first hit is a link to MSDN: MSDN: "DataView.Count Property"[^] which tells you all about it.
What is says is that it returns "the number of records in the DataView after RowFilter and RowStateFilter have been applied."
So the line:
if (DVLocal.Count > 0)
将为true,因此至少有一行要处理的行。
will be true if there are any rows in the view, so at least one line to process.