473,388 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Databind list of dates

I have created an object that has a number of properties, that I am
now trying to simply databind to a form. I am using the data designer
to do it and just dragging and dropping the items onto the form.

Everything works great, except one of the items in my object is a list
of dates. Right now I am using a generic list to hold these, but when
I go to put this item on the form it only lists "None" as the type of
control I can use to represent it.

I just want to list the dates in a combobox so the user can select the
correct one. The dates are coming from a backend database earlier in
the process, so at this point they are actual DateTime objects.

Would it be easier to change them to string and use a type of string
list, then just convert them back with CDate() when I need to use
them? What type of string list is bindable?

Thanks in advance for any help.

Matt
Jun 27 '08 #1
1 1337
Matt,

I cannot get the name, but the most simple sollution with a combobox is to
use a datatable, that goes forever.

\\\
dim dt as new datatable
dim dc as new column("TheDate", System.DateTime)
dt.columns.add(dc)
for each yourdate as datetime in yourlist
dim dr as datarow = dt.rows.newRow
dr.items(dc) = yourdate
dr.rows.Add(dr)
next
yourcombobox.datasource = dt
yourcombobox.valuemember = "TheDate"
yourcombobox.displaymember = "TheDate"
///

Typos or whatever are possible in this because it is typed very quick in
this message.

Cor

"Matt Lowrance" <ma*************@gmail.comschreef in bericht
news:70**********************************@27g2000h sf.googlegroups.com...
>I have created an object that has a number of properties, that I am
now trying to simply databind to a form. I am using the data designer
to do it and just dragging and dropping the items onto the form.

Everything works great, except one of the items in my object is a list
of dates. Right now I am using a generic list to hold these, but when
I go to put this item on the form it only lists "None" as the type of
control I can use to represent it.

I just want to list the dates in a combobox so the user can select the
correct one. The dates are coming from a backend database earlier in
the process, so at this point they are actual DateTime objects.

Would it be easier to change them to string and use a type of string
list, then just convert them back with CDate() when I need to use
them? What type of string list is bindable?

Thanks in advance for any help.

Matt
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
2
by: Kel Good | last post by:
Hello, I am binding a custom IList object to a DataList that I am using for a web menu. The items in the custom IList have properties that allow me to dynamically define how my menu behaves. My...
2
by: Jimmy | last post by:
Hi all I want to databind a dropdownlist in a datagrid: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here
8
by: Notgiven | last post by:
Say you have two dates, 2005-01-01 and 2005-01-24. I want to get a list or array or all the date between and including those two dates. I want to include this list in a query so I need it in a...
5
by: Jurgen Appelo | last post by:
I'm at a loss here... My FormView control automatically performs a databind at each postback on the server. But in some cases I don't want this to happen. Like when the business layer decides that...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
1
by: Mark Olbert | last post by:
I have a GridView as a child control in a custom composite control which is stubornly refusing to databind at design time. I'm convinced I must be missing something about how the databinding process...
0
by: murfu | last post by:
I have a formview that has a dropdownlist bound to a table to populate a list of people. While in edit mode, if a person is not in that list, there is a button that pops up an add requester page...
1
by: jitupatil2007 | last post by:
hi friends i am reading a csv file using string array and after that to keep a validation check i have added the array to list and using list i am accessing the records correctly but i have a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.