Webform DropDownList

Results 1 to 2 of 2

Thread: Webform DropDownList

  1. #1
    Join Date
    Dec 1969

    Default Webform DropDownList

    I&#039;m use a server control drop down and trying to figure out how I can control it a bit more. My goal in all of this is to be able to use the visual aspects of VS as much as possible on simple data entry forms. The autogenerated line looks like this (I chopped out width/ID/etc):<BR><BR>&#060;asp:listbox DataSource="&#060;%# SiteDS1 %&#062;" runat="server" DataMember="Listings" DataTextField="StartDate" DataValueField="ID"&#062;&#060;/asp:listbox&#062;<BR><BR>There are 2 problems with this. The first is that the date is coming out like "5/1/2002 12:00:00 AM", whereas I only want the date. I was reading about the formatting stuff but couldn&#039;t really figure out how to get it to format this nicely. Secondly, what I really want is to include a second field like "5/1/02 at The Lodge" or something like that. The field is in the same table, in the dataset, but I can&#039;t figure out a way to get it to display like that. Help!

  2. #2
    Join Date
    Dec 1969

    Default RE: Webform DropDownList

    I&#039;m not sure, but you may be able to use the DataFormatString property that is present in a DataGrid to clean up your date. Your listbox might look like this:<BR><BR>&#060;asp:listbox DataSource="&#060;%# SiteDS1 %&#062;" <BR> runat="server" <BR> DataMember="Listings" <BR> DataTextField="StartDate" <BR> DataValueField="ID"<BR> DataFormatString = "{0:d}"&#062;<BR>&#060;/asp:listbox&#062;<BR><BR>If not, you can always format your date when you pull it form the data source using something like the following in your select statement:<BR><BR>select StarDate, Format(ActiveDate,"mm/dd/yyyy") from MyTable <BR><BR>As for displaying two fields in a listbox, seems like a DataList or DataGrid control might be easier to use. I guess you could always concatinate the two datafields together before binding to the listbox.<BR><BR>Hope this helps.<BR><BR>Tom T<BR><BR>

Posting Permissions

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