Solved

Pass a null value to an objectdatasource from dropdownlist default

Posted on 2014-07-21
2
383 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:xDJR1875
xDJR1875 earned 250 total points
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Word Template Mail merge with vb.net 4 38
C# Reverse int in fast ways 6 27
Long URL in SMS 6 23
Re-position the objects 7 46
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now