I have a dropdown (selProject) populated by a SQL table. The value is the id field, the name is the name field.
I have a gridview control fed by a sqldatasource.
What I want to do is to conditional where clause based on the selProject dropdown. I have spent 3 hours searching and trying to figure this out. I fear I am going to snap and kill a co-woker.
When I choose a specific value in the dropdown, the selectedValue of the control is "40". I verified this through debugging. This is correct and expected.
I have a controlParameter that looks like:
<asp:ControlParameter ControlID="selProject" PropertyName="SelectedValue" Name="ProjectIDPass" Type="Int32" />
The SelectCommand includes: (Batches.ProjectID = @ProjectIDPass)
as part of the Where clause.
I get no rows, no errors, no problems. The issue I suspect is that the SelectedValue of the dropdown is a string and the Batches.ProjectID is an integer.
When I hard code 40 into the where clause in place of @ProjectIDPass, it works great. When I go back to the ControlParameter is bombs out. I have tried all manner of conversion techniques.
Is there any way to see the SqlDataSouce SelectCommand that was executed with actual values in place of the parameters.
SqlDataSource.Selecting
I am checking the values of the dropdowns selected.index and selected.value and the values are not set yet. So it is feeding values to the SQLDataSource that are invalid, hence pulling no rows. I am sure that this is a problem with the order things are loading on the page. In the contentPlaceHolder section, I am setting the value of the dropdown.selectedvalue from code from a master page variable. From the selecting event, the master page variable is not available yet. Any thoughts? – C Palmer Feb 25 '16 at 13:42