Note that there are some explanatory texts on larger screens.

plurals
  1. POFiltering LINQ query
    primarykey
    data
    text
    <p>I have problem that is bothering me last couple of days.</p> <p>I need to filter LINQ query using comboboxes and textboxes. The problem is I can't manage to get the result and I always get the empty gridview (used for showing filtered data). </p> <p>Can anyone help me why am I getting no results at all? I've checked the debugger and the data sent to query is valid, although, I'm not sure about "string.Empty" value.</p> <p>Here is the code:</p> <pre><code>string naziv, nazivEn, adresa, tel, fax, mob, email, web, oib, tip, mjesto; if (chkMjesto.Checked == true) { mjesto = cbMjesto.SelectedItem.Text; } else { mjesto = string.Empty; } if (chkTip.Checked == true) { tip = cbTip.SelectedItem.Text; } else { tip = string.Empty; } string tema; if (chkTema.Checked == true) { tema = cbTema.SelectedItem.Text; } else { tema = string.Empty; } if (chkAdresa.Checked == true) { adresa = txtAdresa.Text; } else { adresa = string.Empty; } if (chkTelefon.Checked == true) { tel = txtTelefon.Text; } else { tel = string.Empty; } if (chkMobitel.Checked == true) { mob = txtMobitel.Text; } else { mob = string.Empty; } if (chkEmail.Checked == true) { email = txtEmail.Text; } else { email = string.Empty; } if (chkWeb.Checked == true) { web = txtWeb.Text; } else { web = string.Empty; } if (chkOIB.Checked == true) { oib = txtOIB.Text; } else { oib = string.Empty; } if (chkNaziv.Checked == true) { naziv = txtNaziv.Text; } else { naziv = string.Empty; } if (chkNazivEn.Checked == true) { nazivEn = txtNazivEn.Text; } else { nazivEn = string.Empty; } if (chkFax.Checked == true) { fax = txtFax.Text; } else { fax = string.Empty; } if (rblOrganizator.SelectedItem.Value == "Nije") { var pretraga = from t in db.tijeloes where t.tijelo_naziv.Contains(naziv) &amp;&amp; t.tijelo_adresa.Contains(adresa) &amp;&amp; t.tip_tijela.tip_tijela_naziv.Contains(tip) &amp;&amp; t.mjesto.mjesto_naziv.Contains(mjesto) where t.tijelo_telefon.Contains(tel) &amp;&amp; t.tijelo_fax.Contains(fax) &amp;&amp; t.tijelo_email.Contains(email) &amp;&amp; t.tijelo_mob.Contains(mob) &amp;&amp; t.tijelo_web.Contains(web) &amp;&amp; t.tijelo_oib.Contains(oib) &amp;&amp; t.tijelo_naziv_en.Contains(nazivEn) select new { t.tijelo_naziv, t.tijelo_oib,t.tip_tijela.tip_tijela_naziv,t.tijelo_adresa,t.mjesto.mjesto_naziv, t.mjesto.zupanija_drzava.zupanija_naziv}; gvTijelo.DataSource = pretraga; gvTijelo.DataBind(); if (pretraga.Count() != 0) { gvTijelo.HeaderRow.Cells[0].Text = "Naziv"; gvTijelo.HeaderRow.Cells[1].Text = "OIB"; gvTijelo.HeaderRow.Cells[2].Text = "Tip tijela"; gvTijelo.HeaderRow.Cells[3].Text = "Adresa"; gvTijelo.HeaderRow.Cells[4].Text = "Mjesto"; gvTijelo.HeaderRow.Cells[5].Text = "Regionalni centar"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload