コード例 #1
0
        public void Search()
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString);

            string query = "select StudentId, StudentName, Address, Email, Gender, EnrollDate, CourseName from tblStudent where CourseName='" + drpCourseName.SelectedValue + "' ";

            con.Open();
            SqlCommand cmd = new SqlCommand(query, con);

            cmd.ExecuteNonQuery();
            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            sda.Fill(dt);
            GvSearch.DataSource = dt;
            GvSearch.DataBind();
            con.Close();
        }
コード例 #2
0
    //binding Grid
    private void GetGrd()
    {
        DataTable DT = new DataTable();

        try
        {
            DT = BusinessServices.BindTaxRateMapping(txtSearch.Text);
            if (DT.Rows.Count > 0)
            {
                GvSearch.DataSource = DT;
                GvSearch.DataBind();
            }
            else
            {
                lbl_msg.Text = "No records found...";
            }
        }
        catch (Exception ex)
        {
        }
    }