c# - Displaying a default images when the images is null in gridview using templatefield -


I am trying to display an alternative image when the images are meaningless on my gridview, which I displayed to the images To do was use the template field. But I can only type an optional text. There is no way to insert alternative default images. Can you help me

  & lt; Asp: TemplateField & gt; & Lt; HeaderTemplate & gt; Question Image & lt; / HeaderTemplate & gt; & Lt; ItemTemplate & gt; & Lt; Img src = 'data: image / jpg; Base64, & lt;% # Eval ("Question Image")! = System.Dibil. Value? Convert.ToBase64String ((byte []) Eval ("QuestionImage"): string.Empty% & gt; 'Alt = "no image" height = "100" width = "200" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt;  

An option line can be in the database event, you can see that cell Go Columns) and provide the image source. If it is zero, then change it to the default image. For example:

Event: Rotundabound

Get the value of the cell (template column)

  if (! String.IsNullOrEmpty (db.imagePath )) {ImgUser.src = db.imagePath; } Other {imgUser.src = "/ images / default.jpg"; }  

This is a holistic idea, not a precise code, so please ignore any typing or code errors. Secondly, avoid eval.


Comments

Popular posts from this blog

javascript - How to use the code plugin with popcornjs -

Python, converting png to gif using ImageMagick -

android layout hide/show views -