Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

Loop through Datatable and call Modal popup if data not exists

When looping through datable, I am inserting record to DB.  At the same time, I am validating if data "Fedex Rep" from datatable exist in Representative table. If not, I want a Modal screen to pop up, with Gridview. This is for a user to  select Representative name. Afterward, goes to the next row in datatable. I am not sure if possible.
I can use Modal popup with Gridview and allow user to select data from Gridview. How can I trigger Modal to popup while looping through datatable?



1. Loop through Datatable, get representative name ("Fedex Rep")  and others values
2. validate if "Fedex Rep" exists in Representative table
    - if Fedex Rep exists, insert data to ShipmentRequest table with other values
   - if Fedex Rep not exists, pop up Modal ajax control, and allow user to select Rep name from   Gridview
      - insert to DB and  continue looping
 
 
Avatar of VBdotnet2005
VBdotnet2005
Flag of United States of America image

ASKER

Fedex rep is a column name in datatable.
Avatar of srikanthreddyn143
srikanthreddyn143

Why don't you check the Fedex rep before inserting the data?

Loop through datatable and check for Fedex rep.

If no rep  show modal popup

Again need to loop through datatable, if everything looks fine, then start inserting in another for loop.

Code should look something like this!!

Sub Save()

For each prow as datarow in datatable
Check for rep
If no rep show a message and exit sub
Next
For each prow as datarow in datatable
Insert row
Next


End sub

Thanks
Here is my datatable

accountnumber   fedexRep   shipmentdate county state zip orderby
12345                  john doe     5/13/2011      Springfield    ca   jsmith
etc

I am checking john doe if exist on my Representative table,
 if john doe exists,
    insert 12345                  john doe     5/13/2011      Springfield    ca   jsmith
to my Clientorder table

if he does not
 Modal display, allows a user to select other rep or  insert john doe to Representative table
  then insert  12345                  Tom Jones(if user select a different name)    5/13/2011      Springfield    ca   jsmith

#1, I can loop and check rep, no problem, then display Modal pop up and exit?
Could you show me how to do in code behind? I am not 100% sure what you meant.
Sub Save()

1. For each prow as datarow in datatable
Check for rep
If no rep show a message and exit sub
Next
2. For each prow as datarow in datatable
Insert row
Next
End sub
The main reason why I am checking Rep name first is the sometime clients send rep like this

john doe
or john a doe
or jdoe

This is just a sample, Basically, this is the same rep.
i would like to see code behind for sample.
if i understand ur req correctly,    you can show the modalpopup , in code behind like

For Loop
       if (Condition)
            (YOUR MODEL POPUP ID).show()
            Exit For
       End if
Next

Open in new window

For Loop
       if (Condition)
            (YOUR MODEL POPUP ID).show()
            Exit For                                           << what if there are a few that can't find, this wouldn'  work,   would it?
       End if
Next
For Loop
      Loop through Datatable from row 1 to the end and insert row in DB?
Next
Ya that should be the way. See this link for msg box.

http://www.codeproject.com/KB/webforms/NingLiangSimpleControl.aspx
ASKER CERTIFIED SOLUTION
Avatar of srikanthreddyn143
srikanthreddyn143

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial