r3nder
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;
}
}
}
private void dataRepeater1_ItemTemplate_Click(object sender, EventArgs e)
{
MessageBox.Show(Convert.ToString(radLabel3.Text));
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
FindControl does not exist in this context :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got it
task = dataRepeater1.CurrentItem. Controls[" radLabel3" ].Text;
task = dataRepeater1.CurrentItem.
ASKER
pointed me in the right direction - thanks
ASKER