private string getIssues(Int64 number, Int16 mode, Int64 mpId) { DataTable dt = new DataTable(); dt = (DataTable)issuesbal.getIssues(mpId, 50, 0, 0); if (dt.Rows.Count != 0) { JavaScriptSerializer js = new JavaScriptSerializer(); List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >(); Dictionary <string, object> row = null; foreach (DataRow dr in dt.Rows) { DataTable idt = (DataTable)issuesbal.getIssue(Convert.ToInt64(dr[0])); if (idt.Rows.Count != 0) { row = new Dictionary <string, object>(); foreach (DataColumn col in idt.Columns) { row.Add(col.ColumnName.Trim(), idt.Rows[0][col]); } rows.Add(row); } } return(js.Serialize(rows)); } return("[]"); }
protected void ListIssues_ItemDataBound(object sender, RepeaterItemEventArgs e) { try { HiddenField issueId = (HiddenField)e.Item.FindControl("HFIssueId"); DataTable dt = (DataTable)issuesbal.getIssue(Convert.ToInt64(issueId.Value)); DataTable voterDt = (DataTable)issuesbal.getVoters(Convert.ToInt64(issueId.Value)); /****Issues***/ //((Image)e.Item.FindControl("IMGprofilePic")).ImageUrl = dt.Rows[0]["profilePic"].ToString(); if (dt.Rows[0]["profilePic"].ToString() != "" && dt.Rows[0]["profilePic"].ToString() != "undefined") { ((Image)e.Item.FindControl("IMGprofilePic")).ImageUrl = dt.Rows[0]["profilePic"].ToString(); } else if (dt.Rows[0]["profilePic"].ToString() == "" || dt.Rows[0]["profilePic"].ToString() == "undefined") { string destPicFolder = "../images/mp/"; ((Image)e.Item.FindControl("IMGprofilePic")).ImageUrl = destPicFolder + "dummy.jpg"; } ((Label)e.Item.FindControl("LBLpostedBy")).Text = dt.Rows[0]["firstName"].ToString() + " " + dt.Rows[0]["lastName"].ToString(); // ((Label)e.Item.FindControl("LBLpstate")).Text = "Andheri East(Mumbai)"; ((Label)e.Item.FindControl("LBLdt")).Text = ((DateTime)(dt.Rows[0]["postedOn"])).ToString("d-MMM-yyyy hh:mm tt"); /*** voters names ***/ if (voterDt.Rows.Count == 2) { ((Label)e.Item.FindControl("LBLfpname")).Text = voterDt.Rows[0]["firstName"].ToString() + " " + voterDt.Rows[0]["lastName"].ToString() + ","; ((Label)e.Item.FindControl("LBLspname")).Text = voterDt.Rows[1]["firstName"].ToString() + " " + voterDt.Rows[1]["lastName"].ToString(); } else if (voterDt.Rows.Count == 1) { ((Label)e.Item.FindControl("LBLfpname")).Text = voterDt.Rows[0]["firstName"].ToString() + " " + voterDt.Rows[0]["lastName"].ToString(); } else if (voterDt.Rows.Count > 2) { ((Label)e.Item.FindControl("LBLfpname")).Text = voterDt.Rows[0]["firstName"].ToString() + " " + voterDt.Rows[0]["lastName"].ToString() + ","; ((Label)e.Item.FindControl("LBLspname")).Text = voterDt.Rows[1]["firstName"].ToString() + " " + voterDt.Rows[1]["lastName"].ToString() + " and "; ((LinkButton)e.Item.FindControl("LBmore")).Visible = true; ((LinkButton)e.Item.FindControl("LBmore")).Text = (Convert.ToUInt64(dt.Rows[0]["voteCount"]) - 2).ToString() + " " + "more.."; ((Panel)e.Item.FindControl("PopupMenu")).Visible = true; Label lblvotersName = (Label)e.Item.FindControl("votersName"); lblvotersName.Text = ""; voterDt.Rows.RemoveAt(0); voterDt.Rows.RemoveAt(0); foreach (DataRow dr in voterDt.Rows) { lblvotersName.Text += dr["firstName"].ToString() + " " + dr["lastName"].ToString() + "<br/>"; } } else { ((Label)e.Item.FindControl("LBLfpname")).Text = "(None) Be first to vote it"; } ((Label)e.Item.FindControl("LBLIssue")).Text = dt.Rows[0]["issueText"].ToString(); /*** Type of issues Pic ****/ Int64 typeofissue = Convert.ToInt64(dt.Rows[0]["issueType"]); if (typeofissue == 4) { ((Image)e.Item.FindControl("PicIssueType")).ImageUrl = "../images/typeofissues/complaint.png"; } else if (typeofissue == 3) { ((Image)e.Item.FindControl("PicIssueType")).ImageUrl = "../images/typeofissues/recommend.png"; } else if (typeofissue == 2) { ((Image)e.Item.FindControl("PicIssueType")).ImageUrl = "../images/typeofissues/praise.png"; } else { ((Image)e.Item.FindControl("PicIssueType")).ImageUrl = "../images/typeofissues/misc.png"; } ///***** LinkButtonS *****/ ((LinkButton)e.Item.FindControl("LBsupport")).CommandArgument = issueId.Value; ((LinkButton)e.Item.FindControl("LBdeny")).CommandArgument = issueId.Value; ((LinkButton)e.Item.FindControl("LBcomment")).CommandArgument = issueId.Value; ((Button)e.Item.FindControl("btnPost")).CommandArgument = issueId.Value; ((LinkButton)e.Item.FindControl("Report_Abuse")).CommandArgument = issueId.Value; ((LinkButton)e.Item.FindControl("LBmore")).Enabled = false; ///***** Counts values *****/ //((Label)e.Item.FindControl("LBLvoteCount")).Text = dt.Rows[0]["voteCount"].ToString(); ((Label)e.Item.FindControl("LBLsupportCount")).Text = dt.Rows[0]["supportCount"].ToString(); ((Label)e.Item.FindControl("LBLdenyCount")).Text = dt.Rows[0]["denyCount"].ToString(); ((Label)e.Item.FindControl("LBLcommentCount")).Text = dt.Rows[0]["commentCount"].ToString(); ///***** Report check ****/ if (Convert.ToBoolean(dt.Rows[0]["reportAbuse"]) == false) { ((Image)e.Item.FindControl("IMG_Report")).ImageUrl = "../images/flag-black.png"; } else { ((Image)e.Item.FindControl("IMG_Report")).ImageUrl = "../images/flag-red.png"; ((LinkButton)e.Item.FindControl("Report_Abuse")).Enabled = false; } ///*** post link button ***/ //((LinkButton)e.Item.FindControl("btnpost")).CommandArgument = issueId.Value; ((Repeater)e.Item.FindControl("ListComments")).DataSource = (DataTable)commentbal.getComments(Convert.ToInt64(issueId.Value)); ((Repeater)e.Item.FindControl("ListComments")).DataBind(); } catch { throw; } finally { } }