private void GetLastRow()
{
XmlReader reader = XmlReader.Create(XPathFolder + xmlFileFTP, new XmlReaderSettings());
DataSet ds = new DataSet();
ds.ReadXml(reader);
dtgFTP.DataSource = ds.Tables["FTP"];
if (dtgFTP.DataSource == null)
{
if (dtgFTP.Rows.Count > 0)
{
int nRowIndex = dtgFTP.Rows.Count - 1;
object newID = dtgFTP.Rows[nRowIndex].Cells[0].Value;
int ID = Convert.ToInt32(newID) + 1;
txtftpID.Text = ID.ToString();
txtftpID.ReadOnly = true;
}
}
else if (dtgFTP.DataSource != null)
{
if (dtgFTP.Rows.Count > 0)
{
int nRowIndex = dtgFTP.Rows.Count - 2;
object newID = dtgFTP.Rows[nRowIndex].Cells[0].Value;
int ID = Convert.ToInt32(newID) + 1;
txtftpID.Text = ID.ToString();
txtftpID.ReadOnly = true;
}
}
else
{
txtftpID.Text = "1";
txtftpID.ReadOnly = true;
}
reader.Close();
}