Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    16

    Unanswered: Need help adding multiple values to dropdownlists datatextfield

    I'm trying to put a range of dates into the datatextfield of my ddl. I'm using the query:

    string strProps2 = "SELECT sc_id, cast(begin_date AS varchar) + ' - ' + cast(end_date AS varchar) AS XYZ From Archived_Property_Changes WHERE Property_number = " + qryPN + " ORDER BY end_date";

    but it gives me an empty ddl. the datavaluefield shows the correct results, but it's not displaying the correct data from the datatextfield. I removed the casts from the SQL query and it returns:

    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value

    Below is my ddl code:

    SqlCommand objCommandProps2 = new SqlCommand(strProps2, myConnection);
    SqlDataReader objReaderProps2 = objCommandProps2.ExecuteReader();

    ddlArchive.DataSource = objReaderProps2;
    ddlArchive.DataValueField = "sc_id";
    ddlArchive.DataTextField = "XYZ";
    ddlArchive.DataBind();
    ddlArchive.Items.Insert(0, "Select A Period");

    Any thoughts are duely appreciated...

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    I think you're talking about DML, not DDL. In addition, I am somewhat confused when you're talking about getting an error after removing casts. And where qryPN is taken from? It looks like a dynamic SQL, but is done on the front-end...Is it C# you're showing here? It very well may be that qryPN has a NULL value, which results in the entire string to be NULL, thus - "empty ddl." Can you shed some light on all this?

  3. #3
    Join Date
    Sep 2003
    Posts
    16
    sorry, ddl stands for asp.net dropdownlist. yea, it's c#. thx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •