private void LoadSocialMediaList() { Business.Sales.SocialMedia Obj = new Business.Sales.SocialMedia(); Entity.Sales.GetSocialMediaParam Param = new Entity.Sales.GetSocialMediaParam { LinkId = OpportunityId, LinkTypeId = Convert.ToInt32(ActityType.Opportunity) }; gvSocialMedia.DataSource = Obj.GetAllSocialMedia(Param); gvSocialMedia.DataBind(); }
protected void gvSocialMedia_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Save") { SocialMediaMappingId = Convert.ToInt32(e.CommandArgument.ToString()); GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); TextBox txtDescription = (TextBox)row.FindControl("txtDescription"); TextBox txtURL = (TextBox)row.FindControl("txtUrl"); Business.Sales.SocialMedia Obj = new Business.Sales.SocialMedia(); Entity.Sales.SocialMedia Model = new Entity.Sales.SocialMedia { Id = SocialMediaMappingId, Description = txtDescription.Text, LinkId = OpportunityId, LinkTypeId = Convert.ToInt32(ActityType.Opportunity), URL = txtURL.Text, SocialMediaId = Convert.ToInt32(gvSocialMedia.DataKeys[row.RowIndex].Values[0].ToString()) }; int rows = Obj.SaveSocialMedia(Model); if (rows > 0) { SocialMediaMappingId = 0; Message.IsSuccess = true; Message.Text = "Saved Successfully"; } else { Message.IsSuccess = false; Message.Text = "Unable to link."; } Message.Show = true; } } catch (Exception ex) { ex.WriteException(); Message.IsSuccess = false; Message.Text = ex.Message; Message.Show = true; } }