C#中提示信息:索引和长度必须引用该字符串内的位置。参数名:length,请各位指教!
private void GridViewMaster_SelectionChanged(object sender, EventArgs e){
try
{
DataGridViewRow grow = new DataGridViewRow();
grow = GridViewMaster.CurrentRow;
if (grow != null && grow.Cells["Id"].Value.ToString() != "")
{
RowID = grow.Cells["Id"].Value.ToString();
DataRow[] drow = dtMain.Select("Id ='" + RowID + "'");
foreach (DataRow dr in drow)
{
setControlTextClear();
strBillNo = dr["BillNo"].ToString();
strTime = Convert.ToDateTime(dr["ProduceDate"].ToString());
strIsDept = dr["isDept"].ToString();
txt_OrderNo.Text = dr["BillNo"].ToString();
txt_Staff.Text = dr["StaffId"].ToString();
txt_StaffName.Text = dr["StaffName"].ToString();
dt_ProduceDate.Value = Convert.ToDateTime(dr["ProduceDate"].ToString());
txt_WorkOrderNo.Text = dr["WorkOrderNo"].ToString();
dt_ProduceDate.Value = Convert.ToDateTime(dr["ProduceDate"].ToString());
txt_ProduceQty.Text = dr["ProduceQty"].ToString();
txt_standard.Text = dr["standard"].ToString();
txt_ProduceTime.Text = dr["ProduceTime"].ToString();
txt_complement.Text = dr["complement"].ToString();
txt_Remark.Text = dr["remark"].ToString();
txt_BomId.Text = dr["BomId"].ToString();
txt_PartNo.Text = dr["PartNo"].ToString();
txt_PartName.Text = dr["PartName"].ToString();
txt_Approve.Text = dr["CurrentApprove"].ToString();
txt_ApproveStatus.Text = dr["Status"].ToString();
txt_AmountQty.Text = dr["AmountQty"].ToString();
txt_createper.Text = dr["createper"].ToString();
txt_createdate.Text = dr["createdate"].ToString();
txt_modifyper.Text = dr["modifyper"].ToString();
txt_modifydate.Text = dr["modifydate"].ToString();
if (IsStartApprove("ProduceTimeForSPY"))
{
string Obj = ClsAddFlowApprove.GetCurrentApproverStatus(txt_OrderNo.Text);
if (Obj == "待审核" || Obj == "待送审" || Obj == "" || Obj == "已退回")
{
tm_Add.Enabled = true;
cm_Approve.Enabled = true;
cm_MainAddDetail.Enabled = true;
if (Obj == "待审核")
{ cm_Approve.Enabled = false; }
}
else
{
tm_Add.Enabled = false;
cm_Approve.Enabled = false;
cm_MainDelete.Enabled = false;
cm_MainAddDetail.Enabled = false;
cm_MainEdit.Enabled = false;
}//*/
}
else
{
cm_Approve.Enabled = false;
}
if (state == operatestate.Isopt)
setControlTextClear();
}//foreach
}//if
}//try
catch (Exception err)
{
MessageBox.Show("(108)提示信息:" + err.Message.ToString());
}
}