Update a gridview when contact form is closing

Hallo
Hope all are well.
I got a NewCompany form that uses a clickevent to open another form to fill in contact details.
But this then updates field in sql. I want to update the gridview with the new information when the contactform has been filled in.
I created a method to run which is populating the main form, I made it public so can access the method on the contactform.
below the code to update the gridview, this part is working when executing from the NewCompany.
The next code is when I done the update and want to update the form.
public void PopulateGridView()
CreateConnection();
try
con = new SqlConnection(constring);
cmd = new SqlCommand("Select CompanyDetailID, ContactID, Name, Surname, JobTitle, Cellphone, Landline, Extension, Email, Birthday, Notes " +
"from ContactDetails " +
"where CompanyDetailID = @SelectedSubDivID ",con);
cmd.Parameters.AddWithValue("@SelectedCompanyID", SelectCompanyID);
cmd.Parameters.AddWithValue("@SelectedSubDivID", SelectSubdivisionID);
sda = new SqlDataAdapter(cmd);
dt = new DataTable();
sda.Fill(dt);
dgContactInfo.DataSource = dt;
dgContactInfo.Columns[0].Visible = false;
dgContactInfo.Columns[1].Visible = false;
catch (Exception ex)
MessageBox.Show(ex.ToString());
finally
The code from the subform trying to execute the top part.
private void txtSave_Click(object sender, EventArgs e)
if (CheckEntryValidation())
MessageBox.Show("All Filled In");
if (ContactID == 0)
try
CreateConnection();
con = new SqlConnection(constring);
con.Open();
cmd = new SqlCommand("INSERT INTO ContactDetails (CompanyDetailID, Name, Surname, JobTitle, Cellphone, Landline, Extension, " +
"Email, Birthday, Notes) " +
"VALUES (@CompanyDetailIDs, @Names, @Surnames, @JobTitles, @Cellphones, @Landlines, @Extensions, " +
"@Emails, @Birthdays, @Notess) ", con);
cmd.Parameters.AddWithValue("@CompanyDetailIDs", DetailID);
cmd.Parameters.AddWithValue("@Names", this.txtName.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Surnames", this.txtSurname.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@JobTitles", this.txtJobTitle.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Cellphones", this.txtCellphone.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Landlines", this.txtLandline.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Extensions", this.txtExtension.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Emails", this.txtEmail.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Birthdays", dateOnly);
cmd.Parameters.AddWithValue("@Notess", this.txtNotes.Text.ToString().Trim());
cmd.ExecuteNonQuery();
MessageBox.Show("Succesfully added");
NewCompany Updgridview = new NewCompany();
Updgridview.PopulateGridView();
this.Close();
catch (Exception ex)
MessageBox.Show(ex.ToString());
finally
con.Close();
labjac

Hallo Fouad
Thanks for the reply, below the code extractions I tried. it complains about a Null reference not set as a object, (Please see pictures attached). I think I might be doing something wrong. please let me know what parts you need to assist.
Calling the ContactDetailsPopup form form the NewCompany form that got the gridview for updating:
private void txtAddContact_Click(object sender, EventArgs e)
if (SelectSubdivisionID != 0)
GridSelectDetailsID = SelectSubdivisionID;
GridSelectContactID = 0;
ContactDetailsPopup ContactPage = new ContactDetailsPopup(GridSelectContactID, GridSelectDetailsID);
ContactPage.Show();
else
MessageBox.Show("Please select Company and Sub Division first");
The Constructor (I think)..
private NewCompany UpdateMainView;
public ContactDetailsPopup(NewCompany Ncomp)
InitializeComponent();
UpdateMainView = Ncomp;
The Update and save:
private void txtSave_Click(object sender, EventArgs e)
if (CheckEntryValidation())
if (ContactID == 0)
try
CreateConnection();
con = new SqlConnection(constring);
con.Open();
cmd = new SqlCommand("INSERT INTO ContactDetails (CompanyDetailID, Name, Surname, JobTitle, Cellphone, Landline, Extension, " +
"Email, Birthday, Notes) " +
"VALUES (@CompanyDetailIDs, @Names, @Surnames, @JobTitles, @Cellphones, @Landlines, @Extensions, " +
"@Emails, @Birthdays, @Notess) ", con);
cmd.Parameters.AddWithValue("@CompanyDetailIDs", DetailID);
cmd.Parameters.AddWithValue("@Names", this.txtName.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Surnames", this.txtSurname.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@JobTitles", this.txtJobTitle.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Cellphones", this.txtCellphone.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Landlines", this.txtLandline.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Extensions", this.txtExtension.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Emails", this.txtEmail.Text.ToString().Trim());
cmd.Parameters.AddWithValue("@Birthdays", dateOnly);
cmd.Parameters.AddWithValue("@Notess", this.txtNotes.Text.ToString().Trim());
cmd.ExecuteNonQuery();
MessageBox.Show("Succesfully added");
UpdateMainView.PopulateGridViewWithParm(DetailID, ContactID);
this.Close();
catch (Exception ex)
MessageBox.Show(ex.ToString());
finally
con.Close();
The Update Gridview Method on the NewCompany Main page where the gridview is present.
public void PopulateGridViewWithParm(int CompanyID, int SubDivID)
int loc_SelectCompanyID = CompanyID;
int loc_SelectSubDivisionID = SubDivID;
CreateConnection();
try
con = new SqlConnection(constring);
cmd = new SqlCommand("Select CompanyDetailID, ContactID, Name, Surname, JobTitle, Cellphone, Landline, Extension, Email, Birthday, Notes " +
"from ContactDetails " +
"where CompanyDetailID = @SelectedSubDivID ", con);
cmd.Parameters.AddWithValue("@SelectedCompanyID", CompanyID);
cmd.Parameters.AddWithValue("@SelectedSubDivID", SubDivID);
sda = new SqlDataAdapter(cmd);
dt = new DataTable();
sda.Fill(dt);
dgContactInfo.DataSource = dt;
dgContactInfo.Columns[0].Visible = false;
dgContactInfo.Columns[1].Visible = false;
catch (Exception ex)
MessageBox.Show(ex.ToString());
finally
Please note that the updateGridview is working correctly when updated from the NewCompany page where the Gridview is present. 
Regards,
Jacques.
labjac

Similar Messages

  • Oracle Forms in R11i apps Q how to requery when called form is closed

    Scenario:
    I have formA. I am calling another formB from FormA. When I do update on Form B and close the control needs to come back to formA and requery (so I can see changes to the updates done in formB).
    Issue:
    I’m successfully launching formB (using fnd_function.execute) and able to update but when I close formB, I’m not able to requery as the control is not coming back to formA.
    Which event should i use when i close the FormB so i can navigate back to called FormA and Requery. ( i tried exit_form, key-exit, the formB is only closing but unable to go to formA)
    Thank you.

    I'm not 100% sure, but I believe ZOOM should work in your case. A slightly dated but valid explanation is here - http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/fnd/zoom05.htm#codezoom
    Pl see the Application Developer Guide for your release of EBS at http://www.oracle.com/technetwork/documentation/applications-167706.html
    HTH
    Srini

  • Has anyone's Contact Form quit working with the latest Muse update?

    I've removed Captcha, reCaptcha, and still I'm getting the message, "ERROR: An error occurred. Image verification failed. If you believe this is incorrect, please contact your system administrator or go back and re-submit the form." This form worked perfectly last week! I had to resend my Muse file today with some minor changes (using the updated Muse app) and now my Contact Forms cannot be sent... Any ideas on what's going on.
    I don't know if it's related, but the Business Catalyst servers have been extremely slow today!!!

    After having no luck, I finally ended up going back to a slightly older version of the website file (.muse), pulling out the entire old contact form, and rebuilding it with the updated Contact Form widget from the current version of Muse. This worked. I believe there was just some conflict with a piece of old code sitting on the server. I'd suggest when you reload your site, that you do ALL files, rather than just the "modified" pages.

  • When i try to open week cal it loads and then closes after a few seconds...I have checked for updates, turned the phone off then on, closed out of the app and then opened it again...nothing works!  Any suggestions?

    When i try to open week cal it loads and then closes after a few seconds...I have checked for updates, turned the phone off then on, closed out of the app and then opened it again...nothing works!  I have thought about deleting the app from my phone and then reloading it again but I worry that it will delete all my calendar info???  Any suggestions?

    To reset, press and hold the Home and power buttons until the silver apple appears.
    I would delete the app, reset the phone and then download the app again. Your calendar information should be stored on the phone as Week Cal uses the Calendar app information.
    Best of luck.

  • How can I be certain the contact list in my iPod touch updates my computer Outlook contact list when I sync and not go the other way? The options in iTunes are not specific enough.

    How can I be certain the contact list in my iPod touch updates my computer Outlook contact list when I sync and not go the other way? The options in iTunes are not specific enough. In other words, I want to replace the information in my computer Outlook contact list with the data from my iPod touch. 

    How is your iPod configured to sync music from your iTunes library?  In other words, what options and configurations do you have enabled from under the iPod's Summary and Music configuration panes in iTunes?
    B-rock

  • TS1814 I have a 4th gen. IPod Touch with IOS4 and i want to update it, but when I hit the Update button its says "contacting the IPod software server" and then after about 5 seconds it says "ITunes could not connect to the IPod software servers". Please h

    I have a 4th gen. Itouch wiht IOS4 and i want to update it, but when i click the update button in ITunes it says "contacting IPod software server" and it looks like it is loading. However, after about 5 seconds it stops and says "ITunes could not connect to the IPod software server". I found the apple webpage that is supposed to help me, but when i went to the LAN settings in the control panel i found that 'Automatically detect settings" was already checked. I do not know what to do, Please help.

    If yo mean the iPod will not connect to your wifi network:
    Does the iPod connect to other networks?
    Do other devices now connect?
    Try:                  
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on the router
    - Reset network settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • HT1926 I am trying to update my iTunes so I can sync my new iphone 5s and it doesn't recognize the phone, apple support said I need to update my iTunes when I try and do that I get an error message that says " the ITunes update server could not be contact

    I am trying to update my iTunes so I can sync my new iphone 5s and it doesn't recognize the phone, apple support said I need to update my iTunes when I try and do that I get an error message that says " the ITunes update server could not be contacted. Please check your internet connection or try back later.
    My internet works fine and I have tried back dozens of times with same result.

    Did you ever figure out the problem? "Contact Software Manufacturer"?? That sounds ominous... I've got the same issue and I'm pretty durn aggravated right about now....
    Thanks!

  • After 10.8.2 update i can no longer wake my macbook from standby with keyboard when the lid is closed

    I just updated to 10.8.2 and now i can no longer wake my macbook froom standby when the lid is closed, it directly goes back to sleep
    steps to reproduce:
    1. attach secondary monitor and keyboard
    2. close lid
    3. wait 5 seconds for going to standby
    4. press any key on keyboard and type in user-credentials (notice how the 2nd monitor becomes the mainscreen)
    5. wait 5 seconds
    6. standby again
    side note:
    i also have sudo nvram boot-args="iog=0x0" enabled, because i like to not use the integrated screen when its attached to a secondary screen, but since it goes back to standby right after login this is pretty much pointless

    Same here, I think changed something in 10.8.2 that wrecked the "Open-MBP Clamshell Mode."  sigh

  • Contact Form Issues When Email Received.

    Using the standard detailed contact form widget by Adobe, I added a few extra input boxes, I then moved them around so that the 'message' box was at the bottom. When testing the contact form the input from the 'message' box was in the middle with the extra info below it. Obviously this will be unacceptable for clients to get this. so is there a way to fix this?
    An example if I have not explained it properly.
    What my website says:
    Name:
    Phone Number:
    Email:
    Website:
    Budget:
    Message:
    What the email i receive says:
    Name
    Phone Number:
    Email:
    Message:
    Website:
    Budget:
    Thanks in advance for any support!

    Notification would include the box fields in list as they were created , means website and budget field are created after message field so they would be down on the menu.
    Example : Fields created in Form
    Field 1
    Field 2
    Field 3
    - Rearranged the fields :
    Field 3
    Field 1
    Field 2
    Form notification will follow the default hierarchy :
    Field 1
    Field 2
    Field 3
    You would need to delete message field , create website and budget field and then create message filed if you want message filed to be included as last data field in notification email.
    Thanks,
    Sanjit

  • Iphone 5: updating to IOS 7.02 from IOS 7.0 battery runs out really fast down 50% in two hours when the phone is closed

    after updating my Iphone 5 to IOS 7.02 from IOS7.0 (with IOS 7.0 everything was fine) i have a battery life issue.
    my battery runs out really fast down 50% in two hours when the phone is closed.
    could someone help plz?

    I found this article from Google helpful.
    http://howto.cnet.com/8301-11310_39-57604792-285/for-longer-battery-life-change- these-ios-7-settings/
    Cheers

  • Why is Muse not loading/showing contact form content correctly when I hit preview or publish?

    This is my contact form in the design panel.
    This is the preview and published end product.
    I cannot figure out how to show the content boxes, and when I try to fill each section in to send a test email, It tells me there is an error with one of my answers.

    Hi thank you for your reply,
    I managed to find a solution today.
    I am new to web design,so I didn't realise that I wasn't using a 'web safe' font for the content boxes. As soon as I changed the font, my form loaded correctly and is now recieving test messages without a problem.

  • My 'contact' form is not working.  When I send a test contact it returns to my adobe email account this: "Contact Form" has a new form submission.

    My 'contact' form is not working.  When I send a test contact it returns to my adobe email account this:
    "Contact Form" has a new form submission.

    What exactly is not working ? As you have mentioned form submission notification is received in your email account so form process is working I believe but you want the notifications to go to another email account I think.
    Have you added the email address in "Email to" field in form options ? If yes and then also you are not receiving the form , then please provide me the site url and post a screenshot or form with option box open.
    Thanks,
    Sanjit

  • Strange error message when submitting my contact form - what does it mean?

    This site was designed by someone else and taken over by me.  The contact form used to work but now when you type in the fields and hit SUBMIT you get the error message that I've attached.  I've tried changing the code using Godaddy's gdform mailer steps and it's still not working.
    Try:
    www.ducksinaroworganizers.com/contactus.php
    I was also playing around with this one too:
    www.ducksinaroworganizers.com/contactustest.php
    Thank you.

    Your form is apparently trying to send via SMTP through pobox.com instead of from your own domain. pobox.com has probably set up their server to prevent this type of email relay - a good thing.
    Why not send through your own domain's mail server? I know nothing about GoDaddy, though. You might want to give them a call.
    Mark A. Boyd
    Keep-On-Learnin' :-)
    This message was processed and edited by Jive.
    It shall not be considered an accurate representation of my words.
    It might not even have been intended as a reply to your message.

  • HT4972 When I try to update my Ipod 4 touch software from 4.3.5 to the latest version, an error message comes in..."The ipod software update server cannot be contacted"

    When I try to update my Ipod 4 touch software from 4.3.5 to the latest version, an error message comes in..."The ipod software update server cannot be contacted"
    I have also tried downloading a separate 840MB file and manually update, but that doesnt work either

    See the chart below to determine whether you can upgrade your device and what you can upgrade to.
    IPhone, iPod Touch, and iPad iOS Compatibility Chart
         Device                                       iOS Verson
    iPhone 1                                       iOS 3.1.3
    iPhone 3G                                    iOS 4.2.1
    iPhone 3GS                                 iOS 6.1
    iPhone 4                                       iOS 6.1
    iPhone 4S                                    iOS 6.1
    iPhone 5                                       iOS 6.1
    iPod Touch 1                               iOS 3.1.3
    iPod Touch 2                               iOS 4.2.1
    iPod Touch 3                               iOS 5.1.1
    iPod Touch 4                               iOS 6.1
    iPod Touch 5                               iOS 6.1
    iPad 1                                           iOS 5.1.1
    iPad 2                                           iOS 6.1
    iPad 3                                           iOS 6.1
    iPad 4                                           iOS 6.1
    iPad Mini                                      iOS 6.1
    Select the method most appropriate for your situation.
    Upgrading iOS
       1. How to update your iPhone, iPad, or iPod Touch
       2. iPhone Support
       3. iPod Touch Support
       4. iPad Support
         a. Updating Your iOS to Version 6.0.x from iOS 5
              Tap Settings > General > Software Update
         If an update is available there will be an active Update button. If you are current,
         then you will see a gray screen with a message saying your are up to date.
         b. If you are still using iOS 4 — Updating your device to iOS 5 or later.
         c. Resolving update problems
            1. iOS - Unable to update or restore
            2. iOS- Resolving update and restore alert messages

  • Updateing firefox asks to close firefox when it is already closed

    my automatic updater does not work and i was advised to manualy update it.But when i tried, it kept telling me to close fire fox which was already closed. I dont know why but every time you guys have an update my pc goes all wonky and i have a hell of a time to reconfigure it. I am running windows seven and Notons antivirus.

    Hello,
    If you're just closing the browser window, you're not actually quitting the application.  You need to quit the application for Flash Player to install.  There are a few different ways to Quit Safari:
    Quit app from the Dock icon:
    Mouse over the Safari icon in the Dock
    Press CTRL and left-mouse click at the same time
    A menu will display. Click Quit to terminate the application. 
    Use Activity Monitor to terminate Safari:
    Launch Activity Monitor from Appilcations/Utilities/Activity Monitor
    Ensure 'All Processes' are being listed (menu in the upper right)
    Find and select Safari
    Click 'Quit Process' button on the upper left.
    HTH.
    Maria

Maybe you are looking for

  • Reg:FCC to ignore the last field name

    Hi...    I am using FCC in the reciver file adapter. the output structure is like 94,ESSAR,,,,,,,D,0000100226,10000,12/13/1 KURLA EAST,MUMBAI,,400025,006398765432,,2009-03-24 00:00:00.0,0000100226,20202789,,,,SUCCESS,, /home/corpuser/Disbursement/DD

  • What is the latest version of Firefox that will work with Windows ME?

    We were recently given an older Gateway laptop that we intend to use solely as an internet terminal. Alas, it is running Windows ME and I don't even know if it has all the specs to upgrade (and certainly not to Vista, which is the only thing we have

  • Question about push email...

    Hi all, i have a question regarding this push mail tech. how the client will be able to receive a message from the server, without the need for client to check it by it self? Is it true the only way to do that is to by keeping a connection between th

  • Moving Photoshop 6.0 to another computer

    We have a small company that has recently reduced staff. Among those we let go was our graphic artist. Since we will have occasional need for a graphics program I am trying to reinstall the program on my computer but am having problems registering. I

  • Screen wont stay off when turned off via ctrl - shift - eject, turns back on within 5-10 seconds - 10.7.2

    I usually have my MBP next to me and when I'm not using it I either use the hot-corner to turn the screen off or the ctrl - shift - eject keys. But when the screen is off it wakes up within 5-10 seconds every time, nothing I can see has changed since