Sameer Khan

Sameer Khan

  • 1.5k
  • 272
  • 39.4k

Custom Table Error

Apr 20 2015 7:46 AM
Error Message is
Hide Copy Code
Multiple controls with the same ID 'trHop0' were found. FindControl requires that controls have unique IDs.
Hide Expand Copy Code

 DataSet ds3 = new DataSet();
                            ds3 = objOrd.Get_Hop_Period_Data(EmpCode);
 
                            for (int k = 0; k < ds3.Tables[0].Rows.Count; k++)
                            {
                                TableRow trHop = new TableRow();
                                trHop.ID = "trHop" + k;
                                trHop.Height = 25;
                                trHop.CssClass = "table";
                                trHop.Width = new Unit("100%");
                                tblHOPData.Controls.Add(trHop);                               
 
                                int Number = k + 1;
 
                                TableCell tcSr = new TableCell();
                                tcSr.ID = "tcSr" + k;
                                tcSr.CssClass = "label";
                                tcSr.Width = new Unit("10%");
                                tcSr.HorizontalAlign = HorizontalAlign.Left;
                                tcSr.Text = Convert.ToString(Number);
                                trHop.Controls.Add(tcSr);
 
                                TableCell tcComm = new TableCell();
                                tcComm.ID = "tcComm" + k;
                                tcComm.CssClass = "label";
                                tcComm.Width = new Unit("10%");
                                tcComm.HorizontalAlign = HorizontalAlign.Left;
                                tcComm.Text = ds3.Tables[0].Rows[k]["COMM_NAME"].ToString();
                                trHop.Controls.Add(tcComm);
 
                                TableCell tcDesg = new TableCell();
                                tcDesg.ID = "tcDesg" + k;
                                tcDesg.CssClass = "label";
                                tcDesg.Width = new Unit("10%");
                                tcDesg.HorizontalAlign = HorizontalAlign.Left;
                                tcDesg.Text = ds3.Tables[0].Rows[k]["DESG_NAME"].ToString();
                                trHop.Controls.Add(tcDesg);
}