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.