Showing posts with label arraylist. Show all posts
Showing posts with label arraylist. Show all posts

Monday, March 26, 2012

Populate Database from Arraylist

I would like to know how to Populate the SQL Database column using the Arraylist

I'm sure its gonna be INSERT...one example i need

INSERT INTO tempPrice(price) VALUES ( "...............")

How should i declare Arraylist in it? I have a list of values inside the arraylist and i just want the entire column to be filled with it.

Thanks.

HTM

Unfortunately there is no direct way to do this. You have to execute each sql query for each row.

Regards

Saturday, March 24, 2012

Populate Dropdownlist with arraylist

I thought that by using the follwing code that the dropdown value wouldbe the second item mentioned in my list item but it seems to be thefirst that get in the selectedTex as well as the selectedValuefield. Is there something that I am missing so that theselectedValue would be the second item of my listeItem?
Thank you
<code>
'********************************************************************************
'********************************************************************************
Private Sub insertTables()
'********************************************************************************
Dim lstColums As New ArrayList
lstColums.Add(New ListItem("Software", "Cl_Systems.Software"))
lstColums.Add(New ListItem("SystemType", "Cl_Systems.Software"))
lstColums.Add(New ListItem("SystemPurchaseDate", "Cl_Systems.SystemPurchaseDate"))
lstColums.Add(New ListItem("ServicePlan", "Cl_Systems.ServicePlan"))
lstColums.Add(New ListItem("ServicePlan_Purchase", "Cl_Systems.ServicePlan"))
lstColums.Add(New ListItem("ServicePlan_WarrentyEnd", "Cl_Systems.WarrentyEnd"))
lstColums.Add(New ListItem("ServicePlan_RenewalDate", "Cl_Systems.RenewalDate"))
lstColums.Add(New ListItem("BuiltID", "Cl_Systems.BuiltID"))
lstColums.Add(New ListItem("Software Version", "Cl_Systems.Version"))
lstColums.Add(New ListItem("Modules", "Cl_Systems.Modules"))
lstColums.Add(New ListItem("Packages", "Cl_Systems.Packages"))
lstColums.Insert(0, "--Select Field--")
ddFields.DataSource = lstColums
ddFields.DataBind()
End Sub
</code>
You added this "lstColums.Insert(0, "--Select Field--")" at the first posion which is "0" and you didn't set your selectedvalue when the DDL loaded, so the default selectedvalue is the first one.

Event if I take that line away it give me the same result.


Are you really creating the list like this? If so, I suggest either (a) creating a ListItemCollection instead, or (b) skipping the intermediate object altogether and just adding the items to the dropdownlist's Items collection.

Wednesday, March 21, 2012

populating a dropdown list from arraylist of objects

hi there,
i have an arraylist which holds my Customer object, that contains the
customer details, but when i try binding it to a dropdown box, i cant get
the values to appear..
this is what i tried:
customerList.DataSource = Customer.GetAdminList()
customerList.DataBind()
customerList.DataTextField = CType(customerList.DataSource,
Customer).Email.ToString
customerList.DataValueField = CType(customerList.DataSource,
Customer).CustomerID.ToString
customerList.Items.Insert(0, "--ALL CUSTOMERS--")
this error returns me a invalid cast error..so i also tried the normal
method:
customerList.DataSource = DotcoCustomer.GetAdminList()
customerList.DataBind()
customerList.DataTextField = "email"
customerList.DataValueField = "customerID"
customerList.Items.Insert(0, "--ALL CUSTOMERS--")
but this populates the dropdown list with the the values
"Web2004.Customer" - which is my application namespace.Object...'
any help appreciated,
Paul.Rearrange the order of your code:
customerList.DataSource = DotcoCustomer.GetAdminList()
customerList.DataTextField = "email"
customerList.DataValueField = "customerID"
customerList.DataBind()
customerList.Items.Insert(0, "--ALL CUSTOMERS--")
"Paul M" <milsnips@.hotmail.com> wrote in message
news:uf9aWLvQEHA.3568@.TK2MSFTNGP10.phx.gbl...
> hi there,
> i have an arraylist which holds my Customer object, that contains the
> customer details, but when i try binding it to a dropdown box, i cant get
> the values to appear..
> this is what i tried:
> customerList.DataSource = Customer.GetAdminList()
> customerList.DataBind()
> customerList.DataTextField = CType(customerList.DataSource,
> Customer).Email.ToString
> customerList.DataValueField = CType(customerList.DataSource,
> Customer).CustomerID.ToString
> customerList.Items.Insert(0, "--ALL CUSTOMERS--")
> this error returns me a invalid cast error..so i also tried the normal
> method:
>
> customerList.DataSource = DotcoCustomer.GetAdminList()
> customerList.DataBind()
> customerList.DataTextField = "email"
> customerList.DataValueField = "customerID"
> customerList.Items.Insert(0, "--ALL CUSTOMERS--")
>
> but this populates the dropdown list with the the values
> "Web2004.Customer" - which is my application namespace.Object...'
> any help appreciated,
> Paul.
>
>

populating a dropdown list from arraylist of objects

hi there,

i have an arraylist which holds my Customer object, that contains the
customer details, but when i try binding it to a dropdown box, i cant get
the values to appear..

this is what i tried:

customerList.DataSource = Customer.GetAdminList()
customerList.DataBind()
customerList.DataTextField = CType(customerList.DataSource,
Customer).Email.ToString
customerList.DataValueField = CType(customerList.DataSource,
Customer).CustomerID.ToString
customerList.Items.Insert(0, "--ALL CUSTOMERS--")

this error returns me a invalid cast error..so i also tried the normal
method:

customerList.DataSource = DotcoCustomer.GetAdminList()
customerList.DataBind()
customerList.DataTextField = "email"
customerList.DataValueField = "customerID"
customerList.Items.Insert(0, "--ALL CUSTOMERS--")

but this populates the dropdown list with the the values
"Web2004.Customer" - which is my application namespace.Object...??
any help appreciated,

Paul.Rearrange the order of your code:
customerList.DataSource = DotcoCustomer.GetAdminList()
customerList.DataTextField = "email"
customerList.DataValueField = "customerID"
customerList.DataBind()
customerList.Items.Insert(0, "--ALL CUSTOMERS--")

"Paul M" <milsnips@.hotmail.com> wrote in message
news:uf9aWLvQEHA.3568@.TK2MSFTNGP10.phx.gbl...
> hi there,
> i have an arraylist which holds my Customer object, that contains the
> customer details, but when i try binding it to a dropdown box, i cant get
> the values to appear..
> this is what i tried:
> customerList.DataSource = Customer.GetAdminList()
> customerList.DataBind()
> customerList.DataTextField = CType(customerList.DataSource,
> Customer).Email.ToString
> customerList.DataValueField = CType(customerList.DataSource,
> Customer).CustomerID.ToString
> customerList.Items.Insert(0, "--ALL CUSTOMERS--")
> this error returns me a invalid cast error..so i also tried the normal
> method:
>
> customerList.DataSource = DotcoCustomer.GetAdminList()
> customerList.DataBind()
> customerList.DataTextField = "email"
> customerList.DataValueField = "customerID"
> customerList.Items.Insert(0, "--ALL CUSTOMERS--")
>
> but this populates the dropdown list with the the values
> "Web2004.Customer" - which is my application namespace.Object...??
> any help appreciated,
> Paul.