Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-02-06
1
Medium Priority
?
500 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Simple Linear Regression
Six Sigma Control Plans

783 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