I’ve got two views namely Index view and Createdialog view.
The code for index view is:
<p>Search For: </p>
@Html.TextBox("companyName", Model);
and the code for Createdialog view is:
@foreach(var item in Model.branch)
{
<tr>
<td><a href="#">
@Html.DisplayFor(itemModel => item.companyName)
</a></td>
<td>@Html.DisplayFor(itemModel => item.branchName)</td>
<td>@Html.DisplayFor(itemModel => item.address)</td>
<td>
@Html.ActionLink("Delete", "Delete", new { id = item.branchId })
@Html.ActionLink("Select", "Index", new { id = item.companyName })
</td>
</tr>
}
Now I want to do is, to send the value of company id from createdialog view to index dialog view and show the companyName in the textbox when i click the select link. Provide suggestion… thank you.
You don’t “send values” from one View to another in MVC. Instead, you will send data from the View to a Controller action and then display another View.
What you have is close, but what you’ll want to do in the Controller is to accept the
companyNameas an input parameter like this: