Ramco Ramco

Ramco Ramco

  • 439
  • 3.4k
  • 545.7k

Link Button in HtmlTable.Append

Sep 18 2022 2:40 AM

Hi

   I want to add Link Button with OnClick event .

                    BALEmployee bALEmployee = new BALEmployee();
                    htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");
                    htmlTable.Append("<thead><tr><th style='display:none'>#</th><th>Training Number</th><th>Training Type</th><th>Training Module</th><th>Date From/Time</th><th>Date To/Time</th><th>Training Participant</th><th>Mode</th><th>State</th><th>Location</th><th>Trainer</th><th>Status</th><th class='text-center nosort'>Actions</th></tr></thead>");
                    htmlTable.Append("<tbody>");

                    foreach (var colum in Result)
                    {

                        string EmpName = bALEmployee.GetEmpNameByCID(Convert.ToInt32(colum.TrainerID));
                        htmlTable.Append("<tr>");
                        htmlTable.Append("<td style='display:none'>" + colum.TrainingID + "</td>");

                        htmlTable.Append("<td>" + EmpName + "</td>");
                        htmlTable.Append("<td>" + colum.TrainingStatus + "</td>");
                        Button btn = new Button();
                        btn.Text = name;
                        btn.Click += new EventHandler(btn_Click);


                            htmlTable.Append("<td class='text-center'><a id='btnEdit' style='pointer-events: none;cursor: default;text-decoration: none;color: #D4D0C8;' class='list-icons-item text-primary-600' title='Edit' hef='NewTraining.aspx?val=" + AES.Encrypt(colum.TrainingID.ToString()) + "'><i class='icon-pencil7 mr-1'></i></a>  <a id='btnAdd' style='cursor:pointer;' class='list-icons-item text-primary-600' title='Add' hef='Nominee.aspx?val=" + AES.Encrypt(colum.TrainingID.ToString()) + "'><i class='icon-pencil7 mr-1'></i>  </a> <Button text='" + name + "'onClick='" + btn_Click() + "'/> </td>");

                        htmlTable.Append("</tr>");
                    }
                    htmlTable.Append("</tbody>");
                    htmlTable.Append("</table>");

                    PlaceHolderTable.Controls.Add(new Literal { Text = htmlTable.ToString() });
                }

Thanks


Answers (1)