protected void CmbTable_SelectedIndexChanged(object sender, EventArgs e) { if (cmbTable.SelectedIndex != 0) { try { selectTable = cmbTable.SelectedItem.ToString(); Session["selected_table"] = selectTable; ViewState["selectedTbl"] = null; selectedTbl.Clear(); selectedTbl.Add(selectTable); ViewState["selectedTbl"] = selectedTbl; string sqlQuery = "Select * from " + selectTable; SqlCommand command = new SqlCommand(sqlQuery); SqlConnection sqlConn = new SqlConnection((Session["Connection_String"]).ToString()); sqlConn.Open(); command.Connection = sqlConn; SqlDataAdapter adapter = new SqlDataAdapter(command); DataTable dt = new DataTable(); adapter.Fill(dt); sqlConn.Close(); List <string> columnNames = new List <string>(); List <string> numerticCol = new List <string>(); foreach (DataColumn column in dt.Columns) { columnNames.Add(column.ColumnName); if (column.DataType == System.Type.GetType("System.Int32")) { numerticCol.Add(column.ColumnName); } } FieldNameList.DataSource = columnNames; FieldNameList.DataBind(); ckSelectAllBase.Checked = false; ckSelectAllBase.Visible = true; LoadSelectedTable(); OrderbyList.DataSource = columnNames; OrderbyList.DataBind(); } catch (Exception ex) { lblError.Text = ex.ToString(); } } else { ckSelectAllBase.Visible = false; FieldNameList.Items.Clear(); joinSelectedTable.Items.Clear(); OrderbyList.Items.Clear(); } }
protected void btnReset_Click(object sender, EventArgs e) { ViewState["relationPara"] = null; ViewState["relationTbl"] = null; ViewState["relationClmn"] = null; ViewState["baseTblClmn"] = null; ViewState["joinSelectionPara"] = null; ViewState["selectedTbl"] = null; ViewState["selectedTblRelPara"] = null; lblJoin.Text = ""; cmbRlTable.SelectedIndex = 0; cmbTable.SelectedIndex = 0; cmbBaseTblClmn.Items.Clear(); RelationFieldNameList.Items.Clear(); cmbRlColumn.Items.Clear(); joinSelectedTable.Items.Clear(); ckSelectAllBase.Visible = false; ckSelectAllRel.Visible = false; List <string> EMPTY = new List <string>(); FieldNameList.ClearSelection(); FieldNameList.DataSource = EMPTY; FieldNameList.DataBind(); SQLQueryText.Enabled = true; SQLQueryText.Text = null; ResultGrid.DataSource = null; ResultGrid.DataBind(); lblError.Text = ""; ViewState["count"] = null; ViewState["filedSelectionPara"] = null; ViewState["conditionalOpPara"] = null; ViewState["txtValuesPara"] = null; ViewState["ConditionPara"] = null; ViewState["wherePara"] = null; lblWhereTxt.Text = ""; btnResetCond.Visible = false; conditionTbl.Items.Clear(); conditionTblClm.Items.Clear(); conditionalOpCB.SelectedIndex = 0; txtValues.Text = ""; conditionAndOr.SelectedIndex = 0; OrderbyList.Items.Clear(); Session["SelectedData"] = null; }