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.EventArg s e)
{
string createdBy = Session["Salesman_I D"].ToString();
string visitDate = txtDateVisit.Te xt;
string startTime = ddlTimeofVisit. SelectedValue.T oString();
string duration = ddlDuration.Sel ectedValue.ToSt ring();
DataTable dt = dbinsertCustVis it.insertCustVi sit.insertAllDa ta(createdBy, 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("lb lAuditItemID")) .Text).ToString ();
string available = lstItems.Items[x].FindControl((( CheckBox)lstIte ms.FindControl( "cbxAvailable") ).Checked).ToSt ring();
string soldIn = lstItems.Items[x].FindControl((( CheckBox)lstIte ms.FindControl( "cbxSoldin")).C hecked).ToStrin g();
string lvAvailable = lstItems.Items[x].FindControl((( Label)lstItems. FindControl("lb lLastVisitAvail able")).Text).T oString();
string lvSoldIn = lstItems.Items[x].FindControl((( Label)lstItems. FindControl("lb lLastVisitSoldi n")).Text).ToSt ring();
dbinsertCustVis itItems.insertC ustVisitItems.G etAllData(visit ID, auditItemID, available, soldIn, lvAvailable, lvSoldIn);
}
}
so basically I first save the dbInsertCustVis it to a sql table retrieve the visitID and then try to store the listview items selected in report. System.EventArg s 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.
Note that I have the visitID what doesn't work is FindControl items
protected void lbtnSave_Click( object sender, System.EventArg s e)
{
string createdBy = Session["Salesman_I D"].ToString();
string visitDate = txtDateVisit.Te xt;
string startTime = ddlTimeofVisit. SelectedValue.T oString();
string duration = ddlDuration.Sel ectedValue.ToSt ring();
DataTable dt = dbinsertCustVis it.insertCustVi sit.insertAllDa ta(createdBy, 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("lb lAuditItemID")) .Text).ToString ();
string available = lstItems.Items[x].FindControl((( CheckBox)lstIte ms.FindControl( "cbxAvailable") ).Checked).ToSt ring();
string soldIn = lstItems.Items[x].FindControl((( CheckBox)lstIte ms.FindControl( "cbxSoldin")).C hecked).ToStrin g();
string lvAvailable = lstItems.Items[x].FindControl((( Label)lstItems. FindControl("lb lLastVisitAvail able")).Text).T oString();
string lvSoldIn = lstItems.Items[x].FindControl((( Label)lstItems. FindControl("lb lLastVisitSoldi n")).Text).ToSt ring();
dbinsertCustVis itItems.insertC ustVisitItems.G etAllData(visit ID, auditItemID, available, soldIn, lvAvailable, lvSoldIn);
}
}
so basically I first save the dbInsertCustVis it to a sql table retrieve the visitID and then try to store the listview items selected in report. System.EventArg s 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.