I’m writing an asp.net mvc “reservations” app. in c# where in a grid view I have a few statuses of the review process, like “new”, “pending, “approved”, “declined” along with details about each request.
Is it possible for just one review status (“Pending”, for example, ) to be an action link, so a user can click on it and see a checklist of reservation requirements.
Right now I have all statuses as an action link:
columns.Template(o =>
{
%>
<%= Html.ActionLink(o.Status, "Details", new { id = o.ID })%>
<%
}).Title("Status").Width(50);
But I need just one of them, “pending” to be active, and others just to be displayed in a view.
Thank you very much for any help!
Here is a more complete code:
`columns.Bound(o => o.Status);
columns.Template(o =>
{
%>
<% if (o.Status == “New”) { %>
<% using (Html.BeginForm(“Pending”, “ReservationRequests”)) { %>
<%= Html.AntiForgeryToken() %>
<%= Html.Hidden(“ID”, o.ID) %>
<% } %>
<% } %>
<%
}).Title(string.Empty).Width(50);
columns.Template(o =>
{
%>
<% if (o.Status == "Declined" | o.Status == "New" | o.Status == "Pending")
{ %>
<% using (Html.BeginForm("Approve", "ReservationRequests")) { %>
<%= Html.AntiForgeryToken() %>
<%= Html.Hidden("ID", o.ID) %>
<input type="submit" value="Approve" class="submit" />
<% } %>
<% } %>
<%
}).Title(string.Empty).Width(50);
columns.Template(o =>
{
%>
<% if (o.Status == "Approved" | o.Status == "New" | o.Status == "Pending")
{ %>
<% using (Html.BeginForm("Decline", "ReservationRequests")) { %>
<%= Html.AntiForgeryToken() %>
<%= Html.Hidden("ID", o.ID) %>
<input type="submit" value="Decline" class="submit" />
<% } %>
<% } %>
<%
}).Title(string.Empty).Width(50);`
I think what you’re asking for is Conditional Rendering. There are plenty of examples out there. But you could just do something like: