Beispiel #1
0
    protected void IssueList_Click(object sender, EventArgs e)
    {
        string selectedValue = IssueSelectDD.SelectedValue.ToString();

        if (sender == null)
        {
            throw new ArgumentNullException(nameof(sender));
        }

        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }
        conn.Open();

        string sqlstring = string.IsNullOrEmpty(selectedValue) ?
                           "SELECT DISTINCT IssueId, IssueName, IssueDate, IssueStatus FROM SubmitIssuesTable"
            : "SELECT DISTINCT IssueId, IssueName, IssueDate, IssueStatus FROM SubmitIssuesTable WHERE IssueName = '" + selectedValue + "'";

        //SQL Query to add data to fields
        SqlDataAdapter sda = new SqlDataAdapter(sqlstring, conn);

        //Create Dataset and GridView Table
        DataSet ds = new DataSet();

        sda.Fill(ds, "SubmitIssuesTable");
        IssueSelectDD.DataSource = ds.Tables["SubmitIssuesTable"];
        GridViewDrop.DataSource  = ds.Tables["SubmitIssuesTable"];
        IssueSelectDD.DataBind();
        GridViewDrop.DataBind();

        conn.Close();
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (sender == null)
        {
            throw new ArgumentNullException(nameof(sender));
        }

        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        if (!this.IsPostBack)
        {
            IssueSelectDD.Items.Clear();
            using (SqlCommand cmd = new SqlCommand("SELECT DISTINCT IssueId, IssueName FROM SubmitIssuesTable WHERE IssueStatus = 'OPEN'", conn))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn;
                conn.Open();

                IssueSelectDD.DataSource = cmd.ExecuteReader();
                IssueSelectDD.Items.Insert(0, "--Select An Issue--");
                IssueSelectDD.DataTextField  = "IssueName";
                IssueSelectDD.DataValueField = "IssueName";
                IssueSelectDD.DataBind();

                conn.Close();
            }
        }
    }