darma teja

darma teja

  • NA
  • 496
  • 329.2k

Loop problem to insert the data into database.

Nov 22 2013 3:35 AM
Hi All,
I have a loop problem to insert data into my databank.
I have three columns called:

Customer    Order       Canceled?
DarmaCPU          false
               Mouse        false
               Phone        true
               Keyboard    false
Teja        Mobile        false
      Ipad          false
              MP3          false
              CPU          true
I actually got this list from excel file and stored it into aspxgrid.

If canceled == true; than I should not insert into my databank.

I stored this values into List.

List<object> Customer = ASPxGridView1.GetSelectedFieldValues("Customer");
List<object> Order = ASPxGridView1.GetSelectedFieldValues("Order");
List<object> Canceled = ASPxGridView1.GetSelectedFieldValues("Canceled");

// Get index value of canceled == false and stored it into "insertdata";
var insertdata = Enumerable.Range(0, Canceled.Count)
                        .Where(i => Canceled[i].ToString() == "false")
                        .ToList();

for (int i = 0; i < insertdata.Count; i++)
{

if (Customer[insertdata[i]].ToString() != "")
{
//My logic to insert the data into database
//But with the above logic I can insert two rows of data into database.
Darma    CPU
Teja        Mobile


*****I wanted to insert the following data in database*********
Darma    CPU       false
                  Mouse      false           
                Keyboard    false
Teja           Mobile       false
          Ipad        false
                  MP3        false  
}
}


Thanks in advance
Darma