I just inherited this project from another developer and I need to get this running for a demo to a client.
First, let me explain what the situation is.
Essentially, we are dynamically creating a check box list from a data source
- We are storing Names of PDF Files and Specific Values in one field in a table
- They are delimited like so: Name.PDF(comma delimiter),Value(pipe delimiter)|....next pdf,next value...|etc...
- We are splitting the string within loops : See code block below
- You will see "f.Option_Values" or "f.Field_Number" FYI: f = a returned value of a LINQ expression
The following code block is part of a switch statement that determines what control(s) to generate - this just happens to be the one that doesn't work...
pnlcontent.Controls.Add(lbl);
var ck = new CheckBoxList();
ck.ID = f.Field_Number;
ck.Style.Add("float", "left");
foreach (var s in f.Option_Values.Split('|'))
{
string[] st = s.Split('~');
var it = new ListItem(st[0], st[1]);
ck.Items.Add(it);
foreach (var v in val.Split(','))
{
if (v == st[1])
{
it.Selected = true;
}
}
}
tt.TargetControlID = ck.ID;
pnlcontent.Controls.Add(ck);
pnlcontent.Controls.Add(help);
pnlcontent.Controls.Add(ltl);
The error I get is this: Index was outside the bounds of the array.
and it errors out on this line: (see attached image)
string[] st = s.Split('~');
Any thoughts on this would be most appreciated.
PS
Yes, I use a lot of "regions" - just to keep the code neat and tidy... and I know where to find stuff.
Attached image(s)
This post has been edited by mb2000inc: 03 October 2012 - 02:13 PM

New Topic/Question
Reply




MultiQuote






|