Navigation

Friday 8 February 2013

ASP.NET ListView : Find Value of DataSet In ItemDataBound


Code Of ItemDataBound OF ListView1 and Find Value From DataSet In ItemDataBound 

protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
   {
       if (e.Item.ItemType == ListViewItemType.DataItem)
       {
           //get index of listView and then Value of IMG Field
           ListViewDataItem dataitem = (ListViewDataItem)e.Item;

           string IMG = (string)DataBinder.Eval(dataitem.DataItem, "IMG");

           Image IMGFriendPic = (Image)e.Item.FindControl("IMGFriendPic");
           if (IMG != null)
           {
               IMGFriendPic.ImageUrl = "../../images_all/" + IMGFriendPic;
           }
           else
           {
               IMGFriendPic.ImageUrl = "../../images_all/no-image-icon-md.png";
           }
         
       }
   }

No comments:

Post a Comment