Problem With Querystringparameter
Jul 19, 2006
Hi, I'm having problems with the querystring parameter in a SQLDataSource, I think the SelectCommand is not getting the value of the Querystringparameter, here is the code:
<asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT cedula,nombre,direccion FROM clientes WHERE nombre LIKE '%' + @nombre + '%'">
<SelectParameters>
<asp:QueryStringParameter Name="Nombre" QueryStringField="Nombre"/>
</SelectParameters>
</asp:SqlDataSource>
I've tried many things like...
"SELECT cedula,nombre,direccion FROM clientes WHERE nombre LIKE @nombre"
"SELECT cedula,nombre,direccion FROM clientes WHERE nombre LIKE '%' & @nombre & '%'"
"SELECT cedula,nombre,direccion FROM clientes WHERE nombre LIKE '%' + @nombre + '%'"
And nothing work, where's the problem?, I send the value of the SelectCommand of the DataSource and the @name is not replaced by any value.
View 2 Replies
Apr 7, 2008
How do you specify a NULL DefaultValue for a SQLDataSource QueryStringParameter?
I've tried DefaultValue="" and DefaultValue="NULL" among other things, but nothing works, and I haven't found MSDN documentation on this. I have a stored procedure which takes two input parameters as follows:
EXEC @return_value = [dbo].[heading_detail] @site_id = 1, @heading_id = NULL
I'm using a SQLDataSource control to execute the stored procedure. I should get a 15 row result set, but instead I get zero rows when I have a null @heading_id value. Here is my ASP code:
<asp:SqlDataSource ID="HeadingDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="heading_detail" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:SessionParameter Name="site_number" Type="Int32" DefaultValue="1" SessionField="site_number" /> <asp:QueryStringParameter Name="heading_id" Type="Int32" DefaultValue="" QueryStringField="heading_id" /> </SelectParameters> </asp:SqlDataSource>
View 2 Replies
View Related
Apr 4, 2007
Hello,
I am sure there is a way to do this programmatically, but it is just not sinking in yet on how to go about this. I have a page where I use a dropdownlist that goes into a gridview and then the selected item of the gridview into the detailsview (typical explain seen online). So, when selecting from the dropdownlist, the gridview uses a controlparameter for the selectparameter to display the appropriate data in the gridview (and so on for the detailslist).
My question is - I wanted to use this same page when coming in from a different page that would utilize querystring. So, the parameter in the querystring would be for what to filter on in the gridview, so the dropdownlist (and that associated controlparameter) should be ignored.
Any suggestions on how to go about this? I assume there is some check of some sort I should in the code (like if querystring is present, use this querystringparameter, else use the controlparameter), but I am not sure exactly what I should check for and how to set up these parameters programmatically.
Thanks,
Jennifer
View 5 Replies
View Related
Mar 14, 2008
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CollegeDatabaseConnectionString %>" SelectCommand="SELECT employee_datails.* FROM employee_datails WHERE memberid !=@id OR memberid OR memberid==uid"> <SelectParameters> <asp:SessionParameter Name="id" SessionField="userid" /> <asp:QueryStringParameter Name="uid" QueryStringField="memberid" /> </SelectParameters> </asp:SqlDataSource> I tried like this but it is not working. It takes at a time one sessionparameter or querystringparameter. I want if profile.aspx--> then i want session parameter in select queryIf profile.aspx?id=12432---> then i want querystringparameter in select query.
View 2 Replies
View Related