private void DetailsApply() { if (!String.IsNullOrEmpty(CurrentCategoryID)) { DetailSource.SelectParameters["CategoryID"].DefaultValue = CurrentCategoryID; DetailGrid.DataBind(); } }
//protected void preambleLists_SelectedIndexChanged(object sender, EventArgs e) //{ // try // { // var selectedQtype = long.Parse(DropDownList1.SelectedValue); // var QType = _db.T_Question.Select(s => s.PreambleId).Distinct(); // var Qt = _db.T_QuestionTypes.FirstOrDefault(s => s.Id == selectedQtype); // var QTypeCount = QType.Count(); // var QTC = QTypeCount++; // var selectedpreamble = long.Parse(preambleLists.SelectedValue); // if (selectedpreamble == 0) // { // PreambleName.Text = Qt.Name + " " + QTC; // preambleText.Text = ""; // PreamblePreview.Text = ""; // preview.Visible = false; // preambleRow.Visible = true; // preambleNameRow.Visible = true; // } // else if (selectedpreamble != -1 && selectedpreamble != 0) // { // var id = QPid.Value; // if (!(string.IsNullOrEmpty(id))) // { // var preamble = _db.T_QuestionPreamble.FirstOrDefault(s => s.Id == selectedpreamble); // PreamblePreview.Text = ""; // PreambleNamePreview.Text = ""; // preview.Visible = false; // QPid.Value = preamble.Id.ToString(); // PreambleName.Text = preamble.Name; // preambleText.Text = preamble.Body; // preambleNameRow.Visible = true; // preambleRow.Visible = true; // } // else // { // var preamble = _db.T_QuestionPreamble.FirstOrDefault(s => s.Id == selectedpreamble); // PreambleName.Text = ""; // preambleText.Text = ""; // preambleNameRow.Visible = false; // preambleRow.Visible = false; // PreambleNamePreview.Text = preamble.Name; // PreamblePreview.Text = preamble.Body; // preview.Visible = true; // } // } // else // { // PreambleName.Text = ""; // preambleText.Text = ""; // PreamblePreview.Text = ""; // PreambleNamePreview.Text = ""; // preview.Visible = false; // preambleNameRow.Visible = false; // preambleRow.Visible = false; // } // } // catch (Exception ex) // { // ErecruitHelper.SetErrorData(ex, Session); // Response.Redirect("ErrorPage.aspx", false); // } //} protected void PreviewUpload_Click(object sender, EventArgs e) { var tenantId = long.Parse(SessionHelper.GetTenantID(HttpContext.Current.Session)); HttpPostedFile file = QuestionFile.PostedFile; if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); string fullFilePath = Path.GetFullPath(file.FileName); string ext = System.IO.Path.GetExtension(file.FileName); string fileID = Guid.NewGuid().ToString(); string path = ""; // var all = new List<string[]>(); if (Directory.Exists(Server.MapPath("~/UploadedQuestions/"))) { path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext)); // PPath = Path.Combine("~/Passports/", cand.Code + ext); file.SaveAs(path); } else { Directory.CreateDirectory(Server.MapPath("~/UploadedQuestions/")); path = Server.MapPath(Path.Combine("~/UploadedQuestions/", fileID + ext)); // PPath = Path.Combine("~/Passports/", cand.Code + ext); file.SaveAs(path); } var data = File.ReadAllBytes(path); ImportFromExcel import = new ImportFromExcel(); if (ext == ".xls") { import.LoadXls(data); } else if (ext == ".xlsx") { import.LoadXlsx(data); } //first parameter it's the sheet number in the excel workbook //second paramter it's the number of rows to skip at the start(we have an header in the file) List <QuestionUploadModel> all = import.ExcelToList <QuestionUploadModel>(0, 1); var obj = new List <object>(); foreach (var s in all) { obj.Add(new { Question = s.Question, Section = s.Section, A = s.A, B = s.B, C = s.C, D = s.D, E = s.E, Answer = s.Answer }); } DetailGrid.DataSource = obj; DetailGrid.DataBind(); ViewActiveTitle.Value = "Import Preview"; ViewActive.Value = "1"; FileID.Value = path; EXT.Value = ext; resultLbl.Text = ""; //} // QuestionFile.Value = fullFilePath; } }
public void SortGrid(Object sender, GridViewSortEventArgs e) { // Create a DataView from the DataTable. DataView dv = new DataView(dtTableContents); // The DataView provides an easy way to sort. Simply set the // Sort property with the name of the field to sort by. dv.Sort = e.SortExpression; // Re-bind the data source and specify that it should be sorted // by the field specified in the SortExpression property. DetailGrid.DataSource = dv; DetailGrid.DataBind(); }
protected void lnkeditDetail_Click(object sender, EventArgs e) { try{ LinkButton lnkedit = ((LinkButton)sender); var p = lnkedit.Parent; HiddenField hdfID = (HiddenField)p.FindControl("hdfIDDetail"); var idcr = long.Parse(hdfID.Value); if (!(idcr == null)) { var theRec = _db.AuditRecords.FirstOrDefault(s => s.Id == idcr); var details = _db.AuditRecordFields.Where(s => s.AuditRecordId == idcr).ToList(); DetailGrid.DataSource = details; DetailGrid.DataBind(); ViewActiveTitle.Value = theRec.Action + " action on " + theRec.TableName; ViewActive.Value = idcr.ToString(); } } catch (Exception ex) { ErecruitHelper.SetErrorData(ex, Session); Response.Redirect("ErrorPage.aspx", false); } }
public void BindTableData(string TableFilter) { DataRow[] foundRows; DataRow foundRow; foundRows = dtTableTypes.Select("FilterValue = '" + TableFilter + "'"); foundRow = foundRows[0]; DataSet dsTableDetail = new DataSet(); // get the support table data dsTableDetail = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["ReportsConnectionString"].ToString(), "UGEN_SP_Select", new SqlParameter("@tableName", "Tables"), new SqlParameter("@columnNames", foundRow["SelectString"]), new SqlParameter("@whereClause", "TableType = '" + TableFilter + "'")); if ((dsTableDetail.Tables[0] != null) && (dsTableDetail.Tables[0].Rows.Count > 0)) { dtTableContents = dsTableDetail.Tables[0]; // Create a DataView and specify the field to sort by. GridView = new DataView(dtTableContents); GridView.Sort = foundRow["SortField"].ToString(); //DetailGrid.Columns[2].HeaderText = foundRow["Col1Hdr"].ToString(); //DetailGrid.Columns[3].HeaderText = foundRow["Col2Hdr"].ToString(); if (foundRow["DescData"].ToString() != "") { DescLabel.Text = "Description"; DescUpd.Visible = true; DescLabel.Visible = true; } else { DescLabel.Text = ""; DescUpd.Text = ""; DescUpd.Visible = false; DescLabel.Visible = false; } if (foundRow["Col1Hdr"].ToString() != "") { Col1Label.Text = foundRow["Col1Hdr"].ToString(); Col1TextBox.Visible = true; Col1Label.Visible = true; } else { Col1Label.Text = ""; Col1TextBox.Text = ""; Col1TextBox.Visible = false; Col1Label.Visible = false; } if (foundRow["Col2Hdr"].ToString() != "") { Col2Label.Text = foundRow["Col2Hdr"].ToString(); Col2TextBox.Visible = true; Col2Label.Visible = true; } else { Col2Label.Text = ""; Col2TextBox.Text = ""; Col2TextBox.Visible = false; Col2Label.Visible = false; } DetailGrid.DataSource = GridView; DetailGrid.DataBind(); DetailPanel.Visible = true; } else { lblErrorMessage.Text = "No matching records on file"; DetailPanel.Visible = false; } AddButt.Visible = true; }