Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

10 Experts available now in Live!

Get 1:1 Help Now