Reputation: 13
I have some data in a database which I am collection in a control function. I place the returned values in to a structure as below:
For I As Integer = 1 To Mygallery.Length - 1
With Mygallery(I)
Select Case True
Case Counter = 0
Line &= "<tr><td><a href=""" & .Dir & """><img src=""" & .GalleryImage.ToString & """ alt=""" & .Customer_Name.ToString & """ height=""200"" width=""150""/> </a></td>"
Counter = 1
Case Counter = 1
Line &= "<td><a href=""" & .Dir & """><img src=""" & .GalleryImage.ToString & """ alt=""" & .Customer_Name.ToString & """ height=""200"" width=""150""/> </a></td></tr>"
Counter = 0
Case Else
End Select
End With
Next
ViewBag.galleryLine = Line
As you can see I add this to a ViewBag.galleryLine
item. In my html view page I then reference this table style="width:100%">@ViewData("Table")
table
(Had to remove the html code as I could not get it to show)
Anyway the problem is it does not write it as a table but as text!
if I put the text that the viewbag returns straight in to the view it displays correctly. So it not a formatting issue!
Upvotes: 0
Views: 524
Reputation: 125
Use the Html.Raw method, like this
@Html.Raw(ViewData("Table"))
Upvotes: 1