Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

filterizacija dataGridView sa textBoxovima i dateTimePickerima zajedno?

[es] :: .NET :: filterizacija dataGridView sa textBoxovima i dateTimePickerima zajedno?

[ Pregleda: 1981 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

tomislav91

Član broj: 206601
Poruke: 316
*.dynamic.isp.telekom.rs.



+1 Profil

icon filterizacija dataGridView sa textBoxovima i dateTimePickerima zajedno?10.10.2014. u 00:28 - pre 115 meseci

Imam mali problem kod filtriranja.

kod event-a za textChanged uradio sam ovako

Code:

private void textBox1_TextChanged(object sender, EventArgs e)
     {
          

                 BindingSource bs = new BindingSource();
                 bs.DataSource = dataGridView1.DataSource;
                 bs.Filter = "korisnik like '%" + textBox1.Text + "%' AND dogadjaj like '%" + textBox3.Text + "%'";
                 dataGridView1.DataSource = bs;
             
     }

     private void textBox3_TextChanged(object sender, EventArgs e)
     {
        
        
             BindingSource bs = new BindingSource();
             bs.DataSource = dataGridView1.DataSource;
             bs.Filter = "korisnik like '%" + textBox1.Text + "%' AND dogadjaj like '%" + textBox3.Text + "%'";
             dataGridView1.DataSource = bs;
         
     }


I to sad radi, dok sam kod dugmeta uradio

Code:

 private void button1_Click(object sender, EventArgs e)
     {
         if(dateTimePicker1.Value>dateTimePicker2.Value)
         {
             MessageBox.Show("Takav opseg nije moguc. Datum Od mora biti veci od datuma Do.", "Opseg datuma", MessageBoxButtons.OK, MessageBoxIcon.Error);
        

         }
         else{
         
         string query = "select korisnik, dogadjaj, Datum from korisnici, dogadjaji, Tomislav where Datum BETWEEN ? AND ? AND korisnik like '%" + textBox1.Text + "%' AND dogadjaj like '%" + textBox3.Text + "%' ";



OleDbCommand cmd = new OleDbCommand(query, connection);
cmd.Parameters.AddWithValue("SDate", DbType.DateTime).Value = dateTimePicker1.Value;
cmd.Parameters.AddWithValue("EDate", DbType.DateTime).Value = dateTimePicker2.Value;

DataSet ds = new DataSet();
sda= new OleDbDataAdapter();

connection.Open();
sda.SelectCommand = cmd;
sda.Fill(ds, "Tomislav");
dataGridView1.DataSource = ds.Tables[0];
connection.Close();
     }
  }


I sad kada odaberem ime i dogadjaj, i recimo stavim opseg da mi izbaci 3 datuma(tako podesim od tih sto je izbacio prvi filtriranju sa textBoxova), on kao da je dodao jos neke, mislim ima ih vise nego sto je bilo kada sam filtrirao po textBox -ovima. Evo ima slika koja je po koracima(1,2,3)




[Ovu poruku je menjao tomislav91 dana 10.10.2014. u 02:17 GMT+1]
life is the one,take care of them!

http://hardware-software.serbianforum.info/
 
Odgovor na temu

[es] :: .NET :: filterizacija dataGridView sa textBoxovima i dateTimePickerima zajedno?

[ Pregleda: 1981 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.