I have an issue with add functionality
Issue is if i know the customer numbers for ex-408567346 etc ;I can write it in textboxes and by clicking on add button it has to add the customernumbers but its not working
beside add button I have serach button where we can search customernumbers and click on return it will add.
Basically two ways to add
1.Add button ---not working
2.Search button--is working
Here is the code below
private void btnAddCustNum_Click(object sender, System.EventArgs e)
{
ArrayList soldTos = new ArrayList(5);
if (txtCustNum1.Text != "") soldTos.Add(txtCustNum1.Text);
if (txtCustNum2.Text != "") soldTos.Add(txtCustNum2.Text);
if (txtCustNum3.Text != "") soldTos.Add(txtCustNum3.Text);
if (txtCustNum4.Text != "") soldTos.Add(txtCustNum4.Text);
ArrayList companies = proxy.GetCustomerList(soldTos,"");
if (Session["USERSOLDTO"] == null)
{
Session["USERSOLDTO"] = companies;
dgCustomers.DataSource = companies;
dgCustomers.DataBind();
}
else
{
AddToCustomerGrid(companies);
}
Session["UPDATESOLDTOS"] = "true";
}
Any help that could be appreciated

Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 9, 2013, 6:51 PM EDT
As per you search code is working fine right?
can you please share AddToCustomerGrid function code?
in this function are you add customer in to data base or just in memory?
mcfar park9 reputationPosted Jul 10, 2013, 3:23 PM EDT
private void AddToCustomerGrid(ArrayList companies)
{
//add customers to the customer Grid. Don't add duplicate customers
bool addCompany = true;
ArrayList newList = new ArrayList();
ArrayList userList = null;
if (Session["USERSOLDTO"] != null)
{
userList = (ArrayList) Session["USERSOLDTO"];
}
else
{
userList = new ArrayList();
}
foreach (Company tCompany in companies)
{
foreach (Company company in userList)
{
if (tCompany.CompanyId.Equals(company.CompanyId))
{
addCompany = false;
break;
}
}
if (addCompany) userList.Add(tCompany);
addCompany = true;
}
Session["USERSOLDTO"] = userList;
dgCustomers.DataSource = userList;
dgCustomers.DataBind();
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 10, 2013, 7:12 PM EDT
hi,
I think, in your case "companies"(you pass from button click) has already has value ehich one you trying to insert.
so kindly check it..
mcfar park9 reputationPosted Jul 12, 2013, 6:49 AM EDT
mcfar park9 reputationPosted Jul 16, 2013, 10:35 AM EDT