Solved

calling a method on the main form from a usercontrol in a WinForm

Posted on 2013-02-06
1
487 Views
Last Modified: 2013-02-06
I have a uercontrol - in that usercontrol I want to can a meathod to initiate the repeater control
int the user control i am calling the main page and the meathod
 MainView mv = FindForm() as MainView;
                    if (mv != null)
                        mv.ButtonRepeater();

Open in new window

in the main page I am calling the repeater
        internal void ButtonRepeater(object sender, EventArgs e)
        {
            ButtonRepeater();
        }

Open in new window


and when it runs I get an error - the error is "This causes two bindings in the collection to bind to the same property.
Parameter name: binding"

        public void ButtonRepeater()
        {
            if (DesignMode == false)
            {
                radLabel3.Text = "";
                dataRepeater1.DataSource = null;
                BindingSource bindingSource1 = null;
                DataTable dt = null;
                string sqlStr = "";
                string sqlCon = ConfigurationManager.ConnectionStrings["ViewCon"].ToString();
                sqlStr += " SELECT  id, TaskUID, Factory, ItemNumber, ItemName, ExFactoryDate, Customer, ReportDate, InspectorName, BatchCode, OverallResultChina, OverallResultDallas, ";
                sqlStr += " IsDupro, IsFinalRandomInsp, IsTestSamplePull, Uploaded, Downloaded, PDS_CC, WorkmanShip, OnSiteTest, BarcodeVer, Packaging, Packing, Lbl_Print_Mrkg, ";
                sqlStr += " ShipRemarks, IsCOmplete "; 
                sqlStr += " FROM         QC_Inspection ";
                sqlStr += " WHERE     (IsCOmplete IS NULL or IsCOmplete = 0 ) ";
                using(SqlConnection conn = new SqlConnection(sqlCon))
                using(SqlCommand cmd = new SqlCommand(sqlStr,conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    dt = new DataTable();
                    da.Fill(dt);
                    bindingSource1 = new BindingSource();
                    bindingSource1.DataSource = dt;
                    radLabel2.Text = "QC Inspection";
                    radLabel3.DataBindings.Add("Text", bindingSource1, "TaskUID");<<<Error<<<<<
                    radLabel4.DataBindings.Add("Text", bindingSource1, "Factory");
                    dataRepeater1.DataSource = bindingSource1;
                    
                }
            }
        }

Open in new window


I am not getting why there is this error
0
Comment
Question by:r3nder
1 Comment
 
LVL 6

Accepted Solution

by:
r3nder earned 0 total points
ID: 38861988
figured it out
radlabel3.Bindings.Clear();
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question