Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very happy with the whole site and would like to extend my compliments to all of you who work to make it one of the most useful sites (If not THE Most Useful) ...and the easiest to navigate..."

Geography

Where in the world do Tek-Tips members come from?
LindaH (Programmer)
28 Mar 02 12:20
Instead of populating the Items Collection of a DropDownList, I coded my HTML page like this:
    <asp:dropdownlist id=ddlMailState runat="server">      
        <!--#include file="includes/states.inc"-->
    </asp:dropdownlist>
where the include file looked like this:
    <asp:ListItem>AL</asp:ListItem>
    <asp:ListItem>AK</asp:ListItem>
    <asp:ListItem>AZ</asp:ListItem>

           and so on.
When I run the application, the dropdownlist works as expected, but in design view, I get an "Error Creating Control" message on my control and can no longer access its properties.  When I hover over the control, the error message reads, "Parser Error:  Value cannot be null.  Parameter name: path1."

Does anyone know of a way to use an include file as a source for the Items Collection without getting this error?  I don't want to put the State codes in a database and bind the control to the DataSource as there's no need to make a trip to the database for something as simple as this.

Thanks.
Helpful Member!  jfrost10 (Programmer)
28 Mar 02 13:56
well, I have a way for you to be able to load the options from a file instead of a db, but it's a little more complicated than just using an include file (but it'll be more rewarding since it deals with new technology).

http://www.eggheadcafe.com/articles/20011128.asp
is a link to an article that details how you can read in an xml file to your code and dynamically fill the ddl from there. It's really not that hard, and the example the author gives is very easy to understand and duplicate.

Something to consider anyway
:)

Jack
LindaH (Programmer)
28 Mar 02 16:00
This is a great solution!

Now I'm having a problem with the path I specify in the ds.ReadXml() command.  I've included the relative path name (much like I did in the INCLUDE), but it interprets the path as "c:\winnt\system32\includes\XMLStates.xml"

Here's the code I'm using:
    Imports System.Web.UI.WebControls
    Imports System.Data
    Imports System.Xml
    Imports System.Xml.XPath
    Imports System.Xml.Xsl
    Imports System.IO
My Page_Load event calls the following subroutine:
    Private Sub BindStateCodes()
      Dim dsStates as New DataSet

      dsStates.ReadXml("includes/XMLStates.xml")
      ddlMailState.DataSource = dsStates.Tables(0)
      ddlMailState.DataTextField = dsStates.Tables(0).Columns(0).ToString()
      ddlMailState.DataValueField = dsStates.Tables(0).Columns(1).ToString()
      ddlMailState.DataBind
    End Sub
Any ideas?
LindaH (Programmer)
28 Mar 02 16:29
I found the problem.  Code BindStateCodes like this:
    Private Sub BindStateCodes()
            Dim dsStates as New DataSet
            Dim sPath as String
            sPath = Server.MapPath("includes\XMLStates.xml")

             dsStates.ReadXml(sPath)

            ddlMailState.DataSource = dsStates.Tables(0)
            ddlMailState.DataTextField = dsStates.Tables(0).Columns(0).ToString()
            ddlMailState.DataValueField = dsStates.Tables(0).Columns(1).ToString()
            ddlMailState.DataBind
    End Sub

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close