3 Replies - 5070 Views - Last Post: 24 December 2008 - 09:27 AM Rate Topic: -----

#1 chadas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-December 08

Search data based on criteria selected in combobox and textbox

Post icon  Posted 24 December 2008 - 05:57 AM

hi
i have a combobox and textbox i select the column name from database in combobox and when iam entering the data based on column name from combobox the whole record has to be displayed in datagrid...


this is the code iam trying
private void txtSearch_TextChanged(object sender, EventArgs e)
		{
			dt = new DataTable("details");
			string query = cboCriteria.Text;
			foreach (DataRow dr1 in ds.Tables[0].Select(ds.Tables[0].Columns[query].ColumnName + "=" + "'" + txtSearch .Text + "'"))
			{
				dt.Rows.Add(dr1);
				ds1.Tables.Add(dt);
				dgInfo.DataSource = ds1.ToString();
				ok = true;
			}
			if (!ok)
			{
				dgInfo.DataSource = ds.ToString();
			}


Is This A Good Question/Topic? 0
  • +

Replies To: Search data based on criteria selected in combobox and textbox

#2 jjsaw5   User is offline

  • D.I.C Lover
  • member icon

Reputation: 92
  • View blog
  • Posts: 3,063
  • Joined: 04-January 08

Re: Search data based on criteria selected in combobox and textbox

Posted 24 December 2008 - 06:04 AM

:code:
Was This Post Helpful? 0
  • +
  • -

#3 tody4me   User is offline

  • Banned
  • member icon

Reputation: 13
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: Search data based on criteria selected in combobox and textbox

Posted 24 December 2008 - 08:13 AM

Ok, so where's the error?

This post has been edited by tody4me: 24 December 2008 - 08:13 AM

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1660
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Search data based on criteria selected in combobox and textbox

Posted 24 December 2008 - 09:27 AM

Not only when does the error occur, but what is the error you're receiving?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1