The problem is that you've declared an array of
IEnumerable
instances, which contains a single element - the results of your
getBeneficiarydetails
method.
Assuming the
getBeneficiarydetails
method actually returns an
IEnumerable<SomeType>
, where
SomeType
is a class which contains properties called
lastname
and
middlename
, then something like this should work:
IEnumerable<SomeType> requiredData = getBeneficiarydetails();
int index = 0;
foreach (SomeType item in requiredData)
{
switch (index)
{
case 0:
{
txtlname.Text = item.lastname;
txtmiddlename.Text = item.middlename;
break;
}
case 1:
{
txtlnamesecond.Text = item.lastname;
txtmiddlenamesecond.Text = item.middlename;
break;
}
...
}
index++;
}