protected void btnSaveCSV_Click(object sender, EventArgs e) { string shortName = Request.QueryString["shortName"]; NDAR.NDAR_DataStructure ds = NDAR.GetNDARDataStructure(shortName); DataTable dt = NDAR.NDARDataStructureElements_to_DataTable(ds); dt.TableName = "csv"; SpreadsheetGearUtils.SaveDataTableToFile(dt, "testit", "csv"); }
//protected void btnSave_Click(object sender, EventArgs e) //{ // DataTable dt = NDAR.LoadFullDataStructureList("NDAR"); // SaveAllDataStructures(dt); //} //protected void SaveAllDataStructures(DataTable dt) //{ // SQL_utils sql = new SQL_utils(); // SqlParameter p = sql.CreateParam("NDAR_DS", dt); // sql.NonQuery_from_ProcName("spNDAR_Insert_DS", p); //} protected void gvScroll_RowCommand(object sender, GridViewCommandEventArgs e) { //save DSE here if (e.CommandName == "Import flds") { NDAR.NDAR_DataStructure ds = NDAR.GetNDARDataStructure(e.CommandArgument.ToString()); DataTable dse = NDAR.NDARDataStructureElements_to_DataTable(ds); //lblInfo.Text = "nrow = {" + dse.Rows.Count.ToString() + "}"; SQL_utils sql = new SQL_utils(); SqlParameter p = sql.CreateParam("NDAR_DSE", dse); sql.NonQuery_from_ProcName("spNDAR_Insert_DSE", p); //GridView gv_Fields = new GridView(); //gv_Fields.DataSource = dse; //gv_Fields.DataBind(); //Panel_dataElements.Controls.Add(gv_Fields); //Panel_dataElements.Visible = true; } }
protected void LoadDataStructure(string shortName) { SQL_utils sql = new SQL_utils("data"); string source = "UWAC DB"; NDAR.NDAR_DataStructure ds = NDAR.GetNDARDataStructure(shortName); DataTable dt = NDAR.NDAR_DSE_from_DB(shortName); //Get the associated table string uwtable = sql.StringScalar_from_SQLstring("select coalesce(uwtable, 'NONE') uwtable from NDAR_DS where shortname = '" + shortName + "'"); if (dt.Rows.Count == 0) { dt = NDAR.NDARDataStructureElements_to_DataTable(ds); source = "NDAR"; } v1.Text = ds.shortName; v2.Text = ds.title; v3.Text = ds.dataElements.Count.ToString(); v4.Text = source; string ndar_datadict_string = @"https://ndar.nih.gov/ndar_data_dictionary.html?short_name=" + shortName; //linkNDAR_DataDict.PostBackUrl = ndar_datadict_string; //linkNDAR_DataDict.Text = shortName; dynLink.NavigateUrl = ndar_datadict_string; dynLink.Text = shortName; Session["ndar_dataElements"] = dt; griddataElements.DataSource = dt; griddataElements.DataBind(); if (uwtable != "NONE") { LoadUWfields(uwtable); ddlUWtables.Visible = false; btnShowUWtable.Visible = false; btnLinkUWtable.Visible = false; LoadMatchedFlds(shortName); } else { Panel_UWtable.Visible = false; } //List<SqlParameter> ps = new List<SqlParameter>(); //ps.Add(sql.CreateParam("shortname", shortName, "text")); //ps.Add(sql.CreateParam("mode", "count", "text")); //DataTable dt_uwflds = sql.DataTable_from_ProcName("def.spNDAR_matching_UWflds", ps); //GridView gv = new GridView(); //gv.DataSource = dt_uwflds; //gv.DataBind(); //panel_UWfldsinfo.Controls.Add(gv); sql.Close(); }