Solved

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

Posted on 2013-02-06
1
484 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now