I am trying to save some information from textbox controls that have been dynamically created and may have been deleted since their creation. I can provide an array of strings that match a number already being used to save that data to match my list of deleted against. essentially to prevent exceptions from being thrown I need to not try and save data from the deleted textboxes. Here is what I am working with atm:
int TextboxNumber = 0;
for (int pc = 0; pc < Int32.Parse(PrinterCount.Text); pc++)
{
for (int r = 0; r <= 2; r++)
{
TextboxNumber = pc * 3 + r;
if (TextboxNumber != Int32.Parse(deleted[]))
{
TextboxName = "textBox" + TextboxNumber.ToString();
printerinfo = printerinfo + this.Controls[TextboxName].Text + ",";
}
}
using (StreamWriter w = File.AppendText(path))
{
w.WriteLine(printerinfo);
};
printerinfo = "";
}
You can see on Line 6 is where I have this if statement. The deleted[] array can be any series of three numbers such as 0,1,3 or 7,8,9 , or both or more... How would one validate in this situation?
Aucun commentaire:
Enregistrer un commentaire