Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have a form in mainpage.xaml and the contact is added to this from a popup child window.

The child window contains a datagrid of all contacts and the user can check the checkbox of those contacts which he/she want to send message.

For this I have created an object of mainpage class and then assigned the name of all those contact to the textbox of main page, which is readonly.

Here is the code for it in the childwindow.

C#
MainPage objMainPage = new MainPage();

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {

            String contacts = string.Empty;
            for (int i = 0; i < contactlist.Count; i++)
            {
                contacts += contactlistIdea.Fname.ToString() + " ;";
            }
            this.DialogResult = true;
            objMainPage.txtContacts.Text = contacts;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            CheckBox cell_chk = (CheckBox)this.dataGrid1.Columns[4].GetCellContent(e.Row);
            cell_chk.Click += new RoutedEventHandler(cell_chk_Click);
        }

        void cell_chk_Click(object sender, RoutedEventArgs e)
        {
            CheckBox chk = sender as CheckBox;
            bool check = chk.IsChecked.Value;
            newcontacts contacts = chk.DataContext as newcontacts;
            if (check)
            {
                if (!contactlist.Contains(contacts))
                {
                    contactlist.Add(contacts);
                }

            }
            else
            {
                contactlist.Remove(contacts);

            }

        }


But the contacts do not show in the textbox of main page while debugging textbox.text shows all the record as i wants.

I am confused where is the actual problem for this exception.

Please have look at this.

Thanks.........
Posted
Updated 8-May-11 18:58pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900