TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ashok kumar
NA
89
36.2k
image not displaying in the webgrid but its coming from db
Sep 27 2013 5:23 AM
Hi,
Iam using MVc4,with EF ,iam not able to display the image in my webgrid ,but the product name is displaying.IN sql server the productimage column is varbinary(max). when iam running this code iam getting boxes,near that iam getting the text "
System.Byte[],sqlserver image",
Pls help me out
Model code:
public partial class Product
{
public string ProductName { get; set; }
public byte[] PRoductImage { get; set; }
}
Context Class:
public Databases()
: base("name=Databases")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Customer> Customers { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<Product> Products { get; set; }
Controller Code:
public class Default1Controller : Controller
{
public Customer t { get; set; }
public Order t1 { get; set; }
public Product t2 { get; set; }
//
// GET: /Default1/
Databases db = new Databases();
public ActionResult Index()
{
return View(db);
}
}
View Code:
@model MyAPP.Models.Databases
@{
ViewBag.Title = "Index";
var grid = new WebGrid(source: Model.Products, rowsPerPage: 5);
}
@grid.GetHtml(columns: grid.Columns( grid.Column("ProductName", "ProductName"),grid.Column("PRoductImage", header: "Image", format: @<img src="@item.PRoductImage" alt="@item.PRoductImage" width="200px" height="100px" /> ) ) )
<input type="submit" value="insert" />
}
Reply
Answers (
0
)
Parameterized storeprocedur
how to add table headers in repeater while binding...