Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pass a null value to an objectdatasource from dropdownlist default

Posted on 2014-07-21
2
Medium Priority
?
477 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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

773 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