?
Solved

Pass a null value to an objectdatasource from dropdownlist default

Posted on 2014-07-21
2
Medium Priority
?
460 Views
Last Modified: 2014-08-06
Hi, I would like to pass a parameter to an objectdatasource from a dropdownlist.  The first Item of the dropdownlist reads "AllProducts" but when I pass it to the stored proc in the datasource i would actually like it to read null as the default.  How can I do this?

ddlProdSuite.DataSource = pscmd.ExecuteReader();
            ddlProdSuite.DataTextField = "PRODUCT";
            ddlProdSuite.DataValueField = "PRODUCT";
            ddlProdSuite.DataBind();
            psConn.Close();
            ddlProdSuite.Items.Insert(0, "AllProducts");        

Open in new window

0
Comment
Question by:Scarlett72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Assisted Solution

by:Daniel Reynolds
Daniel Reynolds earned 1000 total points
ID: 40209831
Not sure that you will be able to pass a null, but you could do the following:
Pass in a unique value and if the stored proc receives that unique value substitute null once in the stored proc.
0
 
LVL 9

Accepted Solution

by:
xav056 earned 1000 total points
ID: 40209858
Set the default value for the @AllProducts to null in the stored proc.
and in the .NET code check if the value selected is all products than don't pass the parameter,, this way the stored proc will execute with the default b\value being null
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question