Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

My code is calling twice the btndelete method in uitableview

$
0
0

i have a uitableview and in that tableview i have 1 like button whenever i click on that like button it calling twice or sometime it's calling multiple times so how can i get rid from that?

i have implemented the following code

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
// request a recycled cell to save memory
SocialBookPostCell cell = tableView.DequeueReusableCell (cellIdentifier) as SocialBookPostCell;

            // if there are no cells to reuse, create a new one
            if (cell == null) {
                cell = new SocialBookPostCell (cellIdentifier);
            }

            cell.UpdateCell (rowdata [indexPath.Row].ID,
                rowdata [indexPath.Row].Name
                ,rowdata [indexPath.Row].PostedOn
                //, rowdata [indexPath.Row].Image
                , rowdata [indexPath.Row].Message
                ,rowdata [indexPath.Row].LikeCount);

            var lblcommentsize = cell.lblComment.Frame.Size;
            rowheight1 = lblcommentsize.Height+3;


            DAL d = new DAL ();

            cell.btnLike.TouchUpInside += (sender, e) => {

            //  string PostID = rowdata [indexPath.Row].ID;
                string loginID = RetriveState ();
                string result = d.InsertSocialBookPost(loginID,"lorem",rowdata[indexPath.Row].ID,"lorem","like");
                if(result == "success")
                {
                    UIAlertView alert=new UIAlertView();
                    alert.Message="Liked Successfully";
                    alert.AddButton("OK");
                    alert.Show();

                }
                else
                {
                    UIAlertView alert1=new UIAlertView();
                    alert1.Message=result.ToString();
                    alert1.AddButton("OK");
                    alert1.Show();
                }
            };

            tblHeight = tblHeight + rowheight1;
            return cell;
        }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>