473,387 Members | 1,504 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,387 software developers and data experts.

How to store multiple Items from a listview to sql table on button submit

I have a listview that displays items from a sql table, I want to store an update for those items into sql, I know how to do the store function and that is already working, but I need to know how to retrieve the values from the listview, here is my code...

Note that I have the visitID what doesn't work is FindControl items

protected void lbtnSave_Click(object sender, System.EventArgs e)
{

string createdBy = Session["Salesman_ID"].ToString();
string visitDate = txtDateVisit.Text;
string startTime = ddlTimeofVisit.SelectedValue.ToString();
string duration = ddlDuration.SelectedValue.ToString();


DataTable dt = dbinsertCustVisit.insertCustVisit.insertAllData(cr eatedBy, visitDate, startTime, duration);


string visitID = dt.Rows[0]["crmVisitID"].ToString();




for (int x = 0; x < lstItems.Items.Count; x++)
{


string auditItemID = lstItems.Items[x].FindControl(((Label)lstItems.FindControl("lblAudi tItemID")).Text).ToString();
string available = lstItems.Items[x].FindControl(((CheckBox)lstItems.FindControl("cbxA vailable")).Checked).ToString();
string soldIn = lstItems.Items[x].FindControl(((CheckBox)lstItems.FindControl("cbxS oldin")).Checked).ToString();
string lvAvailable = lstItems.Items[x].FindControl(((Label)lstItems.FindControl("lblLast VisitAvailable")).Text).ToString();
string lvSoldIn = lstItems.Items[x].FindControl(((Label)lstItems.FindControl("lblLast VisitSoldin")).Text).ToString();



dbinsertCustVisitItems.insertCustVisitItems.GetAll Data(visitID, auditItemID, available, soldIn, lvAvailable, lvSoldIn);


}

}

so basically I first save the dbInsertCustVisit to a sql table retrieve the visitID and then try to store the listview items selected in report. System.EventArgs does not recognize any of the FindControl items and so I get null error when I click on save visit button. I having trouble retrieving the list items even though I do get a count of Items in my list.
Dec 28 '11 #1
0 1428

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
1
by: Steve | last post by:
I have a listview that can get itself into a situation where multiple items have the LVIS_FOCUSED state. According to the documentation, LVIS_FOCUSED means "The item has the focus, so it is...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
3
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the...
9
by: KMorris | last post by:
I'm working on a database for comment cards (similar to the ones at restaurants with the number scoring) I have 3 boxes at the beginning of each entry I would like to have filled automatically. The...
5
by: rameshbhojan | last post by:
Hi All, Please let me know if there is way in which i we can make multiple selections from a drop down list. The requirement is as follows: I have a drop down list, whose entries are to be...
1
by: c35tar1 | last post by:
I have a ListView within a dialog. In code the groups are created and items added. Display is 100% correct. The problem is with using Shift to select multiple items in the list. - If you...
4
by: swethak | last post by:
hi i wrote a code to select multiple items in a drop down list.And i store all the items in my database.But in that i select multiple items and submit that items last item only stored.Please...
1
by: KrazyKasper | last post by:
Access 2003 – Multi-Column List Box – Select Multiple Items I have a multi-column (3 columns) list box that works well to select one set of records or all sets of records (based on the first field...
1
by: loknath11 | last post by:
I have problem with posting multiple items from sel2 to database without selection.It will so kind from you if you could look my code. ///certificate.php <html> <head> <script...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.