asp.net - Display image in gridview depending on value of column -
i have gridview displays rows , columns linked sql statement... , works normal.
i want include new column, displays image depending on value of column is. if column has value - display image. if column value null no image whill displayed.
my sql like:
select c.call_id, title, a.call_id b_attach calls c left join attachments on c.call_id = a.call_id group c.call_id,title,description, a.call_id
what's returns sql is:
call_id | title | b_attach
1235 | title goes here | 1235
1382 | title |null
so if there's in b_attach - diplay image in gridview column, else display nothing in gridview column
my gridview:
<asp:hyperlinkfield sortexpression="call_id" headertext="call id" datatextfield="call_id" datanavigateurlfields="call_id" datanavigateurlformatstring="showcall.aspx?id={0}" /> <asp:hyperlinkfield sortexpression="title" headertext="title" datatextfield="title" datanavigateurlfields="call_id" datanavigateurlformatstring="showcall.aspx?id={0}" /> </columns>
any ideas on how this?
you can use templatefield
, and, inside this:
<asp:image runat="server" id="myimg" imageurl='<%# getimage(databinder.eval(container.dataitem, "b_attach")) >%' visible='<%# null != databinder.eval(container.dataitem, "b_attach") %> />
Comments
Post a Comment