hay guys...
i m new here and having problem in finding a row through a combobox i did that with a simple text box it is working fine here is the coding
private void btnFind_Click(object sender, EventArgs e)
{
string searchFor = textBox4.Text;
int results = 0;
DataRow[] returnedRows;
returnedRows = ds1.Tables["Workers"].Select("last_Name ='" + searchFor + "'");
results = returnedRows.Length;
if (results > 0)
{
DataRow dr1;
dr1 = returnedRows[0];
MessageBox.Show(dr1["Last_Name"].ToString());
}
else
{
MessageBox.Show("No such Record");
}
}
but now i want to have a combobox from where i can select any of the three columns that is First_Name, Last_Name and Job_Title (i know first name wont be suitable for search but its just prototype) and whatever i select and write respective field in a text box and press find so it should show the respective match here is my code in which m having problem
private void btnFind_Click(object sender, EventArgs e)
{
string searchFor = textBox4.Text;
int results = 0;
DataRow[] returnedRows;
returnedRows = ds1.Tables["Workers"].Select(comboBox1.Text+"='" + searchFor + "'");
results = returnedRows.Length;
if (results > 0)
{
DataRow dr1;
dr1 = returnedRows[0];
MessageBox.Show(dr1[comboBox1.Text].ToString());
}
else
{
MessageBox.Show("No such Record");
}
}