private void BindValues() { DataTable dt = new DataTable(); switch (sType) { case "Project": { dt = Project.GetListDiscussionsDataTable(ProjID); break; } case "Task": { dt = Task.GetListDiscussionsDataTable(TaskID); break; } case "ToDo": { dt = ToDo.GetListDiscussionsDataTable(ToDoID); break; } case "Event": { dt = CalendarEntry.GetListDiscussionsDataTable(EventID); break; } case "Incident": { dt = Incident.GetListDiscussionsDataTable(IncidentID); break; } case "Document": { dt = Document.GetListDiscussionsDataTable(DocumentID); break; } default: { break; } } DataView dv = dt.DefaultView; dv.Sort = "CreationDate DESC"; dgComments.DataSource = dv; dgComments.DataBind(); }
private void BindDataGrid() { dgComments.Columns[1].HeaderText = LocRM.GetString("Text"); dgComments.Columns[2].HeaderText = LocRM.GetString("CreatedBy"); dgComments.Columns[3].HeaderText = LocRM.GetString("CreationDate"); foreach (DataGridColumn dgc in dgComments.Columns) { if (dgc.SortExpression == pcCurrentUser["c_SortColumn"].ToString()) { dgc.HeaderText += " <img border='0' align='absmiddle' width='9px' height='5px' src='../layouts/images/upbtnF.jpg'/>"; } else if (dgc.SortExpression + " DESC" == pcCurrentUser["c_SortColumn"].ToString()) { dgc.HeaderText += " <img border='0' align='absmiddle' width='9px' height='5px' src='../layouts/images/downbtnF.jpg'/>"; } } DataTable dt = new DataTable(); switch (sType) { case "Project": { dt = Project.GetListDiscussionsDataTable(ProjID); break; } case "Task": { dt = Task.GetListDiscussionsDataTable(TaskID); break; } case "ToDo": { dt = ToDo.GetListDiscussionsDataTable(ToDoID); break; } case "Event": { dt = CalendarEntry.GetListDiscussionsDataTable(EventID); break; } case "Incident": { dt = Incident.GetListDiscussionsDataTable(IncidentID); break; } case "Document": { dt = Document.GetListDiscussionsDataTable(DocumentID); break; } default: { break; } } DataView dv = dt.DefaultView; try { dv.Sort = pcCurrentUser["c_SortColumn"]; } catch { pcCurrentUser["c_SortColumn"] = "CreationDate DESC"; dv.Sort = pcCurrentUser["c_SortColumn"]; } dgComments.DataSource = dt.DefaultView; if (pcCurrentUser["c_PageSize"] != null) { dgComments.PageSize = int.Parse(pcCurrentUser["c_PageSize"]); } if (pcCurrentUser["c_Page"] != null) { int pageindex = int.Parse(pcCurrentUser["c_Page"]); int ppi = dt.Rows.Count / dgComments.PageSize; if (dt.Rows.Count % dgComments.PageSize == 0) { ppi = ppi - 1; } if (pageindex <= ppi) { dgComments.CurrentPageIndex = pageindex; } else { dgComments.CurrentPageIndex = 0; } } dgComments.DataBind(); foreach (DataGridItem dgi in dgComments.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarning") + "')"); } } }