I am using Split to split get a number of items from a multi line text box. But I need to be able to get the number of elements within the text box (e.g. if the text box has 2,4,8 in it, I want to be able to count that this text box has 3 elements entered into it). My code is below :
for (int p=0; p < dgNational.Items.Count; p++)
{
strQuantity = ((TextBox)dgNational.Items[p].FindControl("txtAccount")).Text +"\r\n";
string strDelimiter = "/r/n";
char [] Delimiter = strDelimiter.ToCharArray();
string [] strSplit = null;
for (int x=0; x <= 100; x++)
{
strSplit = strQuantity.Split(Delimiter, x);
}
if (strSplit.Length != dgNational.Items.Count)
{
lblErrorNational.Text = "Invalid number of accounts entered";
return;
}
}
Any help would be much appreciated.
Cheers,
lfc77
for (int p=0; p < dgNational.Items.Count; p++)
{
strQuantity = ((TextBox)dgNational.Items[p].FindControl("txtAccount")).Text +"\r\n";
string strDelimiter = "/r/n";
char [] Delimiter = strDelimiter.ToCharArray();
string [] strSplit = null;
for (int x=0; x <= 100; x++)
{
strSplit = strQuantity.Split(Delimiter, x);
}
if (strSplit.Length != dgNational.Items.Count)
{
lblErrorNational.Text = "Invalid number of accounts entered";
return;
}
}
Any help would be much appreciated.
Cheers,
lfc77