sotofuchsia
New Member
I'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><asp:listbox DataSource="<%# SiteDS1 %>" runat="server" DataMember="Listings" DataTextField="StartDate" DataValueField="ID"></asp:listbox><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'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't figure out a way to get it to display like that. Help!I'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><asp:listbox DataSource="<%# SiteDS1 %>" <BR> runat="server" <BR> DataMember="Listings" <BR> DataTextField="StartDate" <BR> DataValueField="ID"<BR> DataFormatString = "{0:d}"><BR></asp:listbox><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>