Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

getting value of a label in a repeater

i have a datarepeater in a win form using C# and I am trying to get the value of a label in the repeater but it keeps comming up as label3 on messagebox.show why wont it give me the value?
        private void ButtonRepeater()
        {
            if (DesignMode == false)
            {
                string sqlStr = "";
                string sqlCon = ConfigurationManager.ConnectionStrings["conn1"].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         Inspection ";
                sqlStr += " WHERE     (IsCOmplete IS NULL) ";
                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);
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    BindingSource bindingSource1 = new BindingSource();
                    bindingSource1.DataSource = dt;
                    radLabel2.Text = "QC Inspection";
                    radLabel3.DataBindings.Add("Text", bindingSource1, "TaskUID");
                    radLabel4.DataBindings.Add("Text", bindingSource1, "Factory");
                    dataRepeater1.DataSource = bindingSource1;
                    
                }
            }
        }

Open in new window


        private void dataRepeater1_ItemTemplate_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Convert.ToString(radLabel3.Text));
        }

Open in new window

SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

I have no HTML - this is winform
Avatar of r3nder

ASKER

FindControl does not exist in this context :(
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

got it
task = dataRepeater1.CurrentItem.Controls["radLabel3"].Text;
Avatar of r3nder

ASKER

pointed me in the right direction - thanks