|
So if I do:
ArrayList arrayitem = new ArrayList();
for (int i = 0; i < listbox1.Items.Count; i++)
{
if (listbox1.Items[i].Selected == true)
{
Session["itemsd"] += listbox1.Items[i].Text + " ";
Session["itemsc"] += listbox1.Items[i].Value + " ";
arrayitem.Add(listbox1.Items[i].Value);
}
}
foreach (string name in arrayitem )
{
}
How can I get the string value from the for each loop and add it into a stored procedure.
So basically for each row in the array I need to insert data into the database with the correct value.
thanks so far
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
try this
ArrayList arr = new ArrayList();
//add values to array list
foreach (object ob in arr)
{
//use ob
}
|
|
|
|
|
How can I loop the arraylist though and get the current value whilst im looping?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
|
I have found some code already but it doesnt seem to be working, Im using the following loop:
for (int i = 0; i < arrayitemdesc.Count; i++)
{
}
In it is a stored procedure which should be inserting data into the database. Im using arrayitemdesc[i] to get the value.
The problem is, nothing is being inserted itto the database.
Why is this?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
.netman wrote: Why is this?
With the information you have provided, there is absolutely no way I could answer this!
|
|
|
|
|
OK here goes
All below code is on the same page
Ive declared this at the start of the class:
ArrayList arrayitemdesc = new ArrayList();
//This code is running on the button event, basically a listbox is displayed, a user chooses some options and then clicks this button. The loop below records all the selected rows in a session.
for (int i = 0; i < listbox1.Items.Count; i++)
{
if (listbox1.Items[i].Selected == true)
{
Session["itemsdesc"] += listbox1.Items[i].Text + " ";
Session["itemscode"] += listbox1.Items[i].Value + " ";
arrayitemdesc.Add(listbox1.Items[i].Value);
}
}
//this code runs when they click the button to add the selected items into the database. For each selected item in the array the stored procedure should fire, however it isnt.
for (int i = 0; i < arrayitemdesc.Count; i++)
{
SqlCommand cmdinsertliftunion = new SqlCommand("INSERT INTO unions (union_code, item_code)
VALUES ('" + new_adb_ref + "', '" + arrayitemdesc[i].ToString() + "')", con);
cmdinsertliftunion.ExecuteNonQuery();
}
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Solved it.
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Good, was there any need to downvote my responses?
|
|
|
|
|
Wow! I didnt downvote your responses.If I was annoyed I would have voted your other response down about starting with a basic tutorial!
<edit> Just seen that post has been downvoted too, still it wasnt me!
<edit> And Now you have deleted the message, very mature
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
modified on Tuesday, October 7, 2008 10:30 AM
|
|
|
|
|
Hi All
I want to have a dynamically generated menu from a dynamically generated web.sitemap file which gets populated from the database. Is it possible.
Your help is greatly appreciated.
Thanks
Ansari
|
|
|
|
|
Hope This will help you
Check It[^] and
This[^]
cheers,
Abhijit
Think Sharp | Code Sharp | C Sharp
|
|
|
|
|
Hi Everyone,
How to check a paypal's email id verified or not programatically? Does paypal give any option for that? Any answers or links welcome.
Thanks
Jegastar D.
|
|
|
|
|
|
Hi All,
I have a requirement of writing an application for sending SMS for free. If anybody know how to send free sms using .Net or VB Script please let me know. I have tried with WebMatrix webservice but its not working. Any ideas about free webservices provided for free sms?
Thanks in Advance
Shahtech
|
|
|
|
|
Good luck mate! I think the era of sending sms messages for free is passed...
|
|
|
|
|
I dont think so there are such free service provider available. you have to paid for it.
cheers,
Abhijit
Think Sharp | Code Sharp | C Sharp
|
|
|
|
|
Hi,
I developed web appln. and run the set up in two local machines. It is working successfully. I run the same setup in my server machine also. But, If I right click the page and browse it, I am getting "The page cannot be displayed". What are the problems will be there? Tnx in adv.
Balasubramanian K.
|
|
|
|
|
BalasubramanianK wrote: ut, If I right click the page and browse it,
What do you mean, do you mean you cant view the webpage at all?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
Yes. I cannot view my page at my server. But I can view in my system.
For ex.
I've run my setup in my system. I can view my page if run the following url in my machine.
http://localhost/EmpDet/EmpDetails.aspx.
The same, I've run the setup in my server named Server15. I cannot view
my page if I run the following url in the server machine it self
http://localhost/EmpDet/EmpDetails.aspx. (I run this in server machine)
If I run in my local machine by using server host. I can see my page.
http://server15/Empdet/EmpDetails.aspx. (I run in my local machine. And I can view my page)
Balasubramanian K.
|
|
|
|
|
be sure asp.net development server is working.if is not,restart your pc.
|
|
|
|
|
I've run my setup in my system. I can view my page if run the following url in my machine.
http://localhost/EmpDet/EmpDetails.aspx.
The same, I've run the setup in my server named Server15. I cannot view
my page if I run the following url in the server machine it self
http://localhost/EmpDet/EmpDetails.aspx. (I cannot view in server machine)
If I run in my local machine by using server host. I can see my page.
http://server15/Empdet/EmpDetails.aspx. (I can view in local machine)
Balasubramanian K.
|
|
|
|
|
This is a bit confusing. You wont be able to see it by going to localhost on your computer as the server is not local.
Is it a web server'/
Are you typing in a URL?
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|
|
http://server15/Empdet/EmpDetails.aspx. (I can view in local machine. Here I am accessing my server)
http://localhost/Empdet/EmpDetails.aspx (Here I can view in my local pc.)
In server machine, I go to my virtual directory of IIS and in the right pan, I can have my all pages. I right click on the start page and click browse. But I am gettng "the page cannot be displayed"
Balasubramanian K.
|
|
|
|
|
Right Click on your application and choose properties and make sure that Under virtual directory tab that there is an application name.
Deliver yesterday, code today, think tomorrow.
"http://www.heuse.com/cphumor.htm"
|
|
|
|