Here is Model
public class candidate_votes
{
public int ff_id_fk { get; set; }
public int cmember_id { get; set; }
public int cparty_id { get; set; }
public int cand_votos { get; set; }
}
Here is View that i am showing data to insert this data into db so that data is in multi values means bulkdata i want every row add in db untill count
foreach (var doc in Model)
{
<div class="row justify-content-center">
<div class="col-sm-2">
<label>Candidate Name</label>
<p>@doc.member_name</p>
<input type="hidden" name="cmember_id[]" value="@doc.member_id" class="form-control" />
</div>
<div class="col-sm-2">
<label>Party Name</label>
<p>@doc.party_name</p>
<input type="hidden" name="cparty_id[]" value="@doc.party_id_fk" class="form-control" />
</div>
<div class="col-sm-2">
<div class="form-group">
<label>Total Votes</label>
<input type="text" name="cand_votos[]" class="form-control" />
</div>
</div>
</div>
}
Here is controller which i am using to post data and on same time first i get data on view with other controller than i am posting that data to this controller
public ActionResult ps_formForty(candidate_votes cand )
{
Dictionary<string, string> data2 = new Dictionary<string, string>();
for (int i = 0; i < cand.cmember_id.count; i++)
{
data2.Add("cmember_id", (cand.cmember_id).ToString());
data2.Add("cparty_id", cand.cparty_id.ToString());
data2.Add("cand_votos", cand.cand_votos.ToString());
DbObject.Insert("candidate_votes", data2);
}
return View();
}
i want something like this and but i couuld not apply loop on candidate_votes cand object Thanks in Advance