Seven price
asked on
combine for loop
I am trying to take two selected items and insert it into the database.
I need to loop through and if first is selected and second is selected insert together.
if only one first is selected and 3 items are selected for second. then it will take the first selected item and insert 3 times with all 3 second items selected.
I need to loop through and if first is selected and second is selected insert together.
if only one first is selected and 3 items are selected for second. then it will take the first selected item and insert 3 times with all 3 second items selected.
example
selected
first Second
3 2
1
4
out put
3 2
3 1
3 4
or
Selected
first second
3 2
4 3
1
out put
3 2
3 3
4 3
4 2
1 2
1 3
for (int j = 0; j < first.Items.Count; j++)
{
if (first.Items[j].Selected)
{
Insert(true,first.Items[j].Value, second.Items[j].Selected);
}
}
for (int j = 0; j < second.Items.Count; j++)
{
if (first.Items[j].Selected,second.Items[j].Selected)
{
Insert(true,first.Items[j].Value);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It is not not working correctly it selects first and second if first is select but not the second in the same row of the list box then it fills it in itself.
example
first second
3 4
2 8 << Not selected
but selects it anyway because 2 is selected in first.
ASKER
thanks, just int a instead of J for the other.
ASKER