You must Sign In to post a response.
  • Category: ASP.NET

    Search button with check boxes

    hi friends,
    how to search the data with check boxes in asp.net
    Thanks and Regards,
  • #763189
    please check the screen shot.

    Delete Attachment

  • #763191
    Hai Sadiq,
    There are 2 ways to get the data filtered based on the checkboxes.
    1. If the data is limited, you can get all the data at once and then when the user checks a checkbox, filter that data and display.
    In this case, you need not to hit the database again and again for the different checkbox checked option.

    var dv = _dsBaseDataSet.Tables[0].DefaultView;
    dv.RowFilter = "filter_criteria";

    2. if the database if big, then you can't use the first approach as it will make the performance degrade for the whole application.
    In this case, you need to get the data from the database each time when you check the checkbox.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #763192
    Thank you for response,
    Can you please send the any source

  • #763205

  • #763209

  • #763223
    Hi,

    protected void Btn_Search_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection Con_CheckBox = new SqlConnection(Connection);
    Con_CheckBox.Open();
    if (Chk_Male.Checked == true)
    {
    string sql = "SELECT * FROM [HumanResources].[Employee] where Gender='M'";
    SqlDataAdapter Adb_CheckBox = new SqlDataAdapter(sql, Con_CheckBox);
    DataSet DS_Check = new DataSet();
    Adb_CheckBox.Fill(DS_Check);
    GridView1.DataSource = DS_Check;
    GridView1.DataBind();
    }
    else
    {
    string sql = "SELECT * FROM [HumanResources].[Employee] where Gender='F'";
    SqlDataAdapter Adb_CheckBox = new SqlDataAdapter(sql, Con_CheckBox);
    DataSet DS_Check = new DataSet();
    Adb_CheckBox.Fill(DS_Check);
    GridView1.DataSource = DS_Check;
    GridView1.DataBind();

    }


    }
    catch (Exception ex)
    {
    ex.Message.ToString();
    }




    }
    }
    }

    Hope this will help

    Regards
    Sriram.R


Sign In to post your comments