Resolved:
FORM 1.
private void btnModificaContractul_Click(object sender, EventArgs e)
{
string[] IDProdusContractPrelugit = new string[dataProduseContract.Rows.Count];
string[] IDProdusContractRetras = new string[dataProduseContract.Rows.Count];
for (int i = 0; i < dataProduseContract.Rows.Count; i++)
{
if (Convert.ToBoolean(dataProduseContract.Rows[i].Cells[0].Value) == false)
{
IDProdusContractPrelugit[i] = dataProduseContract.Rows[i].Cells[5].Value.ToString();
}
else
{
IDProdusContractRetras[i] = dataProduseContract.Rows[i].Cells[5].Value.ToString();
}
}
try
{
frmModificaContract ModificareContract = new frmModificaContract(IDProdusContractPrelugit, IDProdusContractRetras);
ModificareContract.ShowDialog();
}
catch { MessageBox.Show("Trebuie să selectaţi un contract din listă pentru a edita.", "Datele furnizate sunt incomplete."); }
}
FORM 2.
string[] IDProdusContractPrelugit;
string[] IDProdusContractRetras;
public frmModificaContract(string[] IDProdusContractPrelugit, string[] IDProdusContractRetras)
{
InitializeComponent();
this.IDProdusContractPrelugit = IDProdusContractPrelugit;
this.IDProdusContractRetras = IDProdusContractRetras;
AfisareProduseContract();
}
void AfisareProduseContract()
{
foreach (string ContractPrelungit in IDProdusContractPrelugit)
{
if (ContractPrelungit != null)
{
Program.Connection.CommandText = "select * from ContractItems WHERE ContractItemId=@ContractItemId";
Program.Connection.AddParameter("@ContractItemId", ContractPrelungit);
DataTable Table = new DataTable();
Program.Connection.FillDataTable(Table, true);
for (int i = 0; i < Table.Rows.Count; i++)
{
if (String.IsNullOrWhiteSpace(Table.Rows[i]["DeletedId"].ToString()))
{
bool validare;
validare = true;
dataProduseContract.Rows.Add(validare, Table.Rows[i]["Name"].ToString(), Table.Rows[i]["Quantity"].ToString() + " " + Table.Rows[i]["QuantityUnit"].ToString(), Table.Rows[i]["Payment"].ToString(), Table.Rows[i]["Description"].ToString(), Table.Rows[i]["ContractItemId"].ToString());
}
else
{
bool validarescos;
validarescos = false;
dataProduseContract.Rows.Add(validarescos, Table.Rows[i]["Name"].ToString(), Table.Rows[i]["Quantity"].ToString() + " " + Table.Rows[i]["QuantityUnit"].ToString(), Table.Rows[i]["Payment"].ToString(), Table.Rows[i]["Description"].ToString(), Table.Rows[i]["ContractItemId"].ToString());
dataProduseContract.Enabled = false;
}
}
}
}
}
The problem is allwais i have Null value in array.