Thursday, 19 September 2013

doubled values ​​of IEnumerable on cshtml

doubled values ​​of IEnumerable on cshtml

I want to fill an IEnumerable to I build a loop to run through me per
array length. The value will be added to the result list that happens in
the function 2 times ie for users and passwords. Each array has a length
of two values. If I now spend in. Cshtml I get everything twice when one
of the two values ​​is higher
List<Template> result = new List<Template>();
// Password
string[] Password_Array = TemplateModel.Password.Split(',');
for (int i = 0; i < Password_Array.Length; i++)
{
string[] Password = Password_Array[i].Split(';');
result.Add(new Template { Password = Password[0] });
}
// User
string[] User_Array = TemplateModel.User.Split(',');
for (int i = 0; i < User.Length; i++)
{
string[] User = User[i].Split(';');
result.Add(new Template { User = User[0] });
}
the cshtml
@foreach (var item in Model)
{
<tr>
<td width="250px">@item.User</td>
<td width="250px">@item.Password</td>
</tr>
}
only if there are 3 users are only 1 password are still useable 3 "tr" for
nothing loaded
thank you

No comments:

Post a Comment