I am using a SqlDataSource control to pull data for a GridView control. I would like to use a value that is stored in a Hidden Field as part of the where clause. I get an Oracle invalid number error.
The value of the Hidden Field is set on Page_Load and looks something like this:
In the code below, it is placed in the :COUNTY_ID property which is linked to the hidden field.
So, is it possible to tie the hidden field value to the SelectCommand parameter of a SqlDataSource so that it pulls the data? I also thought it might be best to build custom SQL and populate the GridView. I have very little experience with the custom route since I am still new to ASP.NET.
The value of the Hidden Field is set on Page_Load and looks something like this:
Code:
2335 OR B.COUNTY_ID = 2336)
In the code below, it is placed in the :COUNTY_ID property which is linked to the hidden field.
Code:
<asp:HiddenField ID="CountySQL" runat="server" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>"
SelectCommand="SELECT A.TRIBAL_ID, A.COUNTY_ID, A.STATE_ABBR, B.COUNTY_NAME, B.STATE_NAME
FROM TRIBE_COUNTY A, STATE_COUNTY B
WHERE A.COUNTY_ID = B.COUNTY_ID AND
(B.COUNTY_ID = :COUNTY_ID
ORDER BY B.COUNTY_NAME">
<SelectParameters>
<asp:ControlParameter ControlID="CountySQL" Name="COUNTY_ID"
PropertyName="Value" />
</SelectParameters>
</asp:SqlDataSource>
So, is it possible to tie the hidden field value to the SelectCommand parameter of a SqlDataSource so that it pulls the data? I also thought it might be best to build custom SQL and populate the GridView. I have very little experience with the custom route since I am still new to ASP.NET.