I am a fan of codeless databinding. Today i found a problem where i got doubts. A table contains a varchar field where null values are possible. This field is the source for a query with controlparameter. So you need something like
select * from table1 where field like @par1 +'%'
The ugly thing is that when the "field" contains sometimes no value , means <null>, the record is not in the result set if searching for %. I use this % as defaultvalue to get all records if nothing is in the textbox.
<SelectParameters> <asp:ControlParameter ControlID="TextBox1" PropertyName="Text" Name="par1" DefaultValue="%"/> </SelectParameters> The workaround is to change the sql command in sqldatasource to
select * from table1 where IsNull(field,'') LIKE IsNull(@par1+'%','%' )
PS: thanks to Doug Reilly, i got the trick after 2 hours searching from a old posting from him.