Esempio n. 1
0
    protected void CheckBox1_OnCheckedChanged(object sender, EventArgs e)
    {
        string IDs   = "";
        int    CntId = 0;

        for (int i = 0; i < ListView1.Items.Count; i++)
        {
            CheckBox CheckBox1 = (CheckBox)ListView1.Items[i].FindControl("CheckBox1");
            Label    IDLabel   = (Label)ListView1.Items[i].FindControl("IDLabel");

            if (CheckBox1.Checked)
            {
                IDs += (IDs != "" ? "," : "") + IDLabel.Text;
                CntId++;
            }
        }
        if (IDs != "")
        {
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdTag2", IDs);
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdTag1", "1");
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdTag3", CntId.ToString());
            //Response.Write(SqlDataSourceFAQ.SelectCommand);
            SqlDataSourceFAQ.Select(DataSourceSelectArguments.Empty);
            SqlDataSourceFAQ.DataBind();
        }
        GridView1.DataBind();
    }
Esempio n. 2
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string IDs   = "";
        int    CntId = 0;

        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            DropDownList DropDownList1 = (DropDownList)GridView2.Rows[i].Cells[1].FindControl("DropDownList1");
            if (DropDownList1.SelectedValue != "0" && DropDownList1.SelectedValue != "")
            {
                IDs += (IDs != ""? ",":"") + DropDownList1.SelectedValue;
                CntId++;
            }
        }
        if (IDs != "")
        {
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdReferenceData2", IDs);
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdReferenceData1", "1");
            SqlDataSourceFAQ.SelectCommand = SqlDataSourceFAQ.SelectCommand.Replace("@IdReferenceData3", CntId.ToString());
            //Response.Write(SqlDataSourceFAQ.SelectCommand);
            SqlDataSourceFAQ.Select(DataSourceSelectArguments.Empty);
            SqlDataSourceFAQ.DataBind();
        }
        GridView1.DataBind();
    }