473,804 Members | 3,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1384
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.da tasource = dt
yourcombobox.va luemember = "TheDate"
yourcombobox.di splaymember = "TheDate"
///

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

Cor

"Matt Lowrance" <ma************ *@gmail.comschr eef in bericht
news:70******** *************** ***********@27g 2000hsf.googleg roups.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
1576
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 method from a separate class file that returns a DataReader, where when I code the DataReader in the .aspx file it does. Below are the details and code of what I am runnign into. I appreciate any help/insight you can provide.
2
3952
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 binding syntax is standard: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MenuItems.DataSource = GetMyCustomIList MenuItems.DataBind()
2
1256
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
14980
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 format like: '2005-01-01', '2005-01-02',... Any ideas? thanks
5
2200
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 some of the information in the controls cannot be accepted. But then the FormView binds to the datasource again, and the input in all contols is lost. And the user will have to type it all over again. In ASP.NET 1.1 we could simply say: If Not...
1
15799
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 list the dates between the start and end date. Basically I am doing a day of the week analysis and need to know which day of the week is busiest.
1
4131
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 works differently at design time. Here is the code that constructs the GridView in CreateChildControls(): gridSearch = new GridView(); gridSearch.AutoGenerateColumns = true; CommandField cmdField = new CommandField();
0
1522
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 and the new name is added to the table. However, when the popup closes, the parent page appears to refresh but the new name is not immediately in the dropdownlist. I have to get out of edit or go to another page and come back to see it. I tried...
1
1195
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 problem when i keep a validation check then i can't get the desired output i have written the code like : StreamReader sr = new StreamReader(@"C:\Documents and Settings\jitendra\Desktop\Copy of ric_mar.csv"); StreamWriter sw = new...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.