Hello, all.
I'm attempting to create a search box using C#.NET. Thus far, I've got this code:
In C#.NET, there is no such thing as "BindingSou rce" so I am kind of stuck in a rut. I deleted the Gridview and replaced it with a FormView, however I am not sure where to go from here as far as the code goes. Does anyone have any guidance?
Thanks.
I'm attempting to create a search box using C#.NET. Thus far, I've got this code:
Code:
protected void SearchBox_TextChanged(object sender, EventArgs e)
{
DataView DV = new DataView(dbDataSet);
DV.RowFilter = string.Format("CourseNum LIKE '%(0)%'", SearchBox.Text);
dataGridView1.DataSource = DV;
}
protected void Button1_Click(object sender, EventArgs e)
{
string error = "Error";
string constring = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
SqlConnection conDataBase = new SqlConnection(constring);
SqlCommand cmdDataBase = new SqlCommand(" select * from ASPNETDB.CourseNum ;", conDataBase);
try{
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmdDataBase;
DataTable dbdataset = new DataTable();
sda.Fill(dbdataset);
BindingSource bsource = new BindingSource();
bsource.DataSource = dbdataset;
dataGridView1.DataSource = bsource;
sda.Update(dbdataset);
}catch(Exception ex){
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + error + "');", true);
}
Thanks.