Link to home
Start Free TrialLog in
Avatar of Spike
Spike

asked on

Populating a gridview from an SQL using an outerjoin and ISNULL

I'm using an outerjoin with ISNULL as follows to populate a gridview on a webpage:

SELECT id,thing1,ISNULL(valid, 0)  as Valid
FROM things as d  left OUTER JOIN thing2 r  ON d.ID=r.parentThingID  
WHERE d.ID =1
 
Which returns the correct results (thanks guys!)

but

when I try to populate the grridview, the checkboxes fail to "check" based on the value in valid:

i.e. Checked='<%# Convert.ToBoolean(Eval("Valid")) %>'/>

The check box gets populated fine if I'm just using a straight queary without using the ISNULL. (where none of the values are null).

Cheers
Avatar of Pratima
Pratima
Flag of India image

Not sure why its not working for you

try this query , Instade of Null use Case

SELECT id,thing1,
Case When valid = 1 then 'True' else 'False' End as Valid
ISNULL(valid, 0)  as Valid
FROM things as d  left OUTER JOIN thing2 r  ON d.ID=r.parentThingID  
WHERE d.ID =1
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Spike
Spike

ASKER

It wasn't working for me as I'm an idiot!
I had linked the wrong IDs and hence it was always null.
You can have the points for at least trying!
Cheers!