Solved

Pass a null value to an objectdatasource from dropdownlist default

Posted on 2014-07-21
2
416 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 250 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 250 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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