G
Guest
I am having a problem stopping a loop and making reference to a control. I
receive errors regarding not being able to find the control and can not stop
the loop. The following is the code I am using (while this code may not
make logical sense, it is necessary that I use it this way).
foreach (Control repeaterControls in repeaterFields.Controls)
{
foreach (Control childc in repeaterControls.Controls)
{
foreach (Control ctrl in childc.Controls)
{
if (ctrl.ID == "aaaa")
{
FileUpload fuCtrl =
(FileUpload)childc.FindControl(((FileUpload)ctrl).ID.ToString());
if (fuCtrl.PostedFile.FileName.ToString().Trim().Length > 0)
{
//use this value as the value passed to UseThisvalue()
then end this loop meaning do not go to the hidden field block
UseThisValue(fuCtrl.PostedFile.FileName.ToString());
//need to end here and not go to the hidden field block
because there is something in the upload control textbox
}
}
if (ctrl.ID == "aaaaBBBB")
{
HiddenField hdnTheString =
(HiddenField)childc.FindControl(((HiddenField)ctrl).ID.ToString());
if (hdnTheString.Value.ToString().Trim().Length > 0)
{
if (fuCtrl.PostedFile.FileName.ToString().Trim().Length
== 0)
{
// use the value from the hidden field because there is nothing in the
file upload path
UseThisValue(hdnTheString.Value.ToString())
//because there is nothing in the fileupload text
use this value
}
}
}
}
}
}
The problem is that within the hiddenfield loop the code cannot see the
fileupload control and determine if there is text in it. While looping I
need to determine if there is text in the fileupload control and if so, use
that text, NOT the value in the hidden field. However, if and only if there
is no value in the fileupload control I need to use the value in the hidden
field. These values are passed to another function but I only need the one
value. Errors I'm receiving are regarding finding the fileupload within the
hiddenfield loop. I also cannot seem to stop the loop after finding a value
in the fileupload control. Any comments would be greatly appreciated.
receive errors regarding not being able to find the control and can not stop
the loop. The following is the code I am using (while this code may not
make logical sense, it is necessary that I use it this way).
foreach (Control repeaterControls in repeaterFields.Controls)
{
foreach (Control childc in repeaterControls.Controls)
{
foreach (Control ctrl in childc.Controls)
{
if (ctrl.ID == "aaaa")
{
FileUpload fuCtrl =
(FileUpload)childc.FindControl(((FileUpload)ctrl).ID.ToString());
if (fuCtrl.PostedFile.FileName.ToString().Trim().Length > 0)
{
//use this value as the value passed to UseThisvalue()
then end this loop meaning do not go to the hidden field block
UseThisValue(fuCtrl.PostedFile.FileName.ToString());
//need to end here and not go to the hidden field block
because there is something in the upload control textbox
}
}
if (ctrl.ID == "aaaaBBBB")
{
HiddenField hdnTheString =
(HiddenField)childc.FindControl(((HiddenField)ctrl).ID.ToString());
if (hdnTheString.Value.ToString().Trim().Length > 0)
{
if (fuCtrl.PostedFile.FileName.ToString().Trim().Length
== 0)
{
// use the value from the hidden field because there is nothing in the
file upload path
UseThisValue(hdnTheString.Value.ToString())
//because there is nothing in the fileupload text
use this value
}
}
}
}
}
}
The problem is that within the hiddenfield loop the code cannot see the
fileupload control and determine if there is text in it. While looping I
need to determine if there is text in the fileupload control and if so, use
that text, NOT the value in the hidden field. However, if and only if there
is no value in the fileupload control I need to use the value in the hidden
field. These values are passed to another function but I only need the one
value. Errors I'm receiving are regarding finding the fileupload within the
hiddenfield loop. I also cannot seem to stop the loop after finding a value
in the fileupload control. Any comments would be greatly appreciated.