This question is locked. New answers and comments are not allowed.
So, I have this bit of code:
What I am trying to achieve is a different image based upon the type_id. But I just can't get it to work.
The error message I am getting is:
CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
And it is pointing to this line:
@<img src="@Url.Content(@url)" alt="@name" width="32" height="32" />;
More specifically the first @. I have tried @<text> and @() but it is always the same.
Could someone give me a hand please.
@(Html.Telerik().Grid(Model) .Name("Grid") .Columns(columns => { columns.Template(o => { string url = "~/Content/Graphics/{0}"; string name = "Twitter"; switch (o.type_id) { case 1: // Twitter url = string.Format(url, "twitter.png"); name = "Twitter"; break; case 2: // Facebook url = string.Format(url, "facebook.png"); name = "Facebook"; break; case 3: // Linked In url = string.Format(url, "linkedin.png"); name = "Linked in"; break; case 4: // Google Plus url = string.Format(url, "Google+.png"); name = "Google Plus"; break; default: url = string.Format(url, "twitter.png"); name = "Twitter"; // Twitter break; } @<img src="@Url.Content(@url)" alt="@name" width="32" height="32" />; }); columns.Bound(o => o.from_user).Title("From"); columns.Bound(o => o.text).Title("Message"); columns.Bound(o => o.date_created).Title("Date").Format("{0:d}"); columns.Template(@<text> @Html.ActionLink("Edit", "Edit", new { id = item.id} ) | @Html.ActionLink("Delete", "Delete", new { id = item.id } ) | @Html.ActionLink("Approve", "Approve", new { id = item.id }) </text>).Width(150).Title("Actions"); }) .CellAction(cell => { if (cell.Column.Member == "Approved") { bool approved = cell.DataItem; if (approved) { cell.HtmlAttributes["style"] = "background-color: Red;"; } } }) .Groupable() .Sortable() .Pageable() .Filterable())What I am trying to achieve is a different image based upon the type_id. But I just can't get it to work.
The error message I am getting is:
CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
And it is pointing to this line:
@<img src="@Url.Content(@url)" alt="@name" width="32" height="32" />;
More specifically the first @. I have tried @<text> and @() but it is always the same.
Could someone give me a hand please.