With little help of you I made this two QUERY
. I posted pictures so you can see that in green squares
are empty values which I would like to see and in
If I'm understanding what you're after, this is the part that's keeping you from getting the rows with no entries in klisluz:
WHERE zajsluz.akce= '{0}' and klisluz.subkey ='" + vyberradek + "'
For the rows that don't exist in klisluz, subkey will be NULL, which won't match anything with that WHERE clause. To get these rows as well, you can replace your current WHERE clause with:
WHERE zajsluz.akce= '{0}' and ISNULL(klisluz.subkey, '" + vyberradek + "') ='" + vyberradek + "'
Here's the full line of code:
string sQuery = string.Format("SELECT zajsluz.akce,zajsluz.text,klisluz.pocet,klisluz.subkey,zajsluz.ID FROM zajsluz LEFT JOIN klisluz ON zajsluz.ID=klisluz.IDzajsluz WHERE zajsluz.akce= '{0}' and ISNULL(klisluz.subkey, '" + vyberradek + "') = '" + vyberradek + "' GROUP BY klisluz.subkey,zajsluz.akce,zajsluz.text,klisluz.pocet,zajsluz.ID", sZakce);
To determine whether the checkbox should be checked:
if (precti3.HasRows)
{
precti3.Read();
if (precti3.Item("subkey") != Null)
{
row.Cells[5].Value = true;
}
else
{
row.Cells[5].Value = false;
}
}
I think that's how it'd go in C#. I work in VB.NET, used an online converter for this.