I bound image button to data in datalist, (image url saved) How to prevent show image button when data have not image.(image url=empty) because in this case (image url=empty) the image button show whit no image whit X
bind Visible property of the button like this
Visible ='<%# Eval("ImageUrl") == System.DbNull.Value ? False : True %>'
oned_gk
bind Visible property of the button like this
Visible ='<%# Eval("ImageUrl") == System.DbNull.Value ? False : True %>'
This is not work:
VB?
Try this
Visible ='<%# Not Isdbnull(Eval("ImageUrl")) %>'
oned_gk
VB?
Try this
Visible ='<%# Not Isdbnull(Eval("ImageUrl")) %>'
this is not work, when the imagurl = null the imagebutton show whit X
protected void dlstControl_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
((ImageButton)e.Item.Controls[Your ImageButton Index]).Visible =
((YourDataSourceType)e.Item.DataItem).ImageUrlProperty == null ? true : false;
//OR
((ImageButton)e.Item.Controls[Your ImageButton Index]).Visible =
((ImageButton)e.Item.Controls[Your ImageButton Index]).ImageUrl == null ? true : false;
}
}
mehr_83
this is not work, when the imagurl = null the imagebutton show whit X
Make sure the value is null instead empty string
For empty string try this
Visible ='<%# IIF(Eval("ImageUrl")="",false,true) %>'
oned_gk
VB?
Try this
Visible ='<%# Not Isdbnull(Eval("ImageUrl")) %>'
excuse me, this is work.
but
how to check the imagurl isempty and not checkto null
Make all empty string
ISNULL(IMAGEURL,'') as IMG
String.IsNullOrEmpty(Convert.ToString(Eval("ImageUrl")))? ...
沒有留言:
張貼留言