I am generating an html table dynamically in my code behind file

```
    protected void PopulateMemberTable()
    {
        var guid = "";
        string[] selectedColumns = new[] { "MEMBID", "MEMBER_NAME", "BIRTH", "IPA", "HPNAME" };
        if (Session["guid"] != null)
            guid = Session["guid"].ToString();
        StringBuilder html = new StringBuilder();
        DataTable dt = MemberSearch(guid, membFirst.Text.ToString(), membLast.Text.ToString(), membDob.Text.ToString(), membId.Text.ToString());
        if (dt != null)
        {
            DataTable new_dt = new DataView(dt).ToTable(false, selectedColumns);        
            html.Append("<table class='table table-hover data-table'>");
            html.Append("<thead>");
            html.Append("<tr>");

            foreach (DataColumn column in new_dt.Columns)
            {
                html.Append("<th>");
                switch(column.ColumnName.ToString())
                {
                    case "MEMBID":
                        html.Append("Member ID");
                        break;
                    case "MEMBER_NAME":
                        html.Append("Member Name");
                        break;
                    case "BIRTH":
                        html.Append("DOB");
                        break;
                    case "IPA":
                        html.Append("IPA");
                        break;
                    case "HPNAME":
                        html.Append("Health Plan");
                        break;
                }
                html.Append("</th>");

            }
            //btn column (no header)
            html.Append("<th></th>");
            html.Append("</tr>");
            html.Append("</thead>");
            html.Append("<tbody>");
            var counter = 0;
            foreach (DataRow row in new_dt.Rows)
            {
                counter++;
                string btnId = "\"" + "<%btnMembGrid" + counter.ToString() + ".ClientId%>" + "\"";
                html.Append("<tr onclick='document.getElementById(" + btnId + ").click()'>");
                var btnValue = new StringBuilder();                  
                foreach(DataColumn column in new_dt.Columns)
                {             
                    html.Append("<td>");
                    html.Append(row[column.ColumnName]);
                    btnValue.Append(row[column.ColumnName]);
                    btnValue.Append(";");
                    html.Append("</td>");  
                }
                html.Append("<td><asp:button runat='server' OnClick='selectMember' CssClass='btn btn-default' style='display:none' value = '"
                    + btnValue.ToString() + "' id= 'btnMembGrid" + counter.ToString() +  "'/></td>");
                html.Append("</tr>");
            }
            html.Append("</tbody>");
            html.Append("</table>");
        }
        else
            html.Append("<div class='alert alert-danger' role='alert'>No Members Found</div>");

        membTable.Controls.Add(new Literal { Text = html.ToString() });

    }

```

The table is generated just fine, but now I am trying to call some server side code when a row is clicked

```
            foreach (DataRow row in new_dt.Rows)
            {
                counter++;
                string btnId = "\"" + "<%btnMembGrid" + counter.ToString() + ".ClientId%>" + "\"";
                html.Append("<tr onclick='document.getElementById(" + btnId + ").click()'>");
                var btnValue = new StringBuilder();                  
                foreach(DataColumn column in new_dt.Columns)
                {             
                    html.Append("<td>");
                    html.Append(row[column.ColumnName]);
                    btnValue.Append(row[column.ColumnName]);
                    btnValue.Append(";");
                    html.Append("</td>");  
                }
                html.Append("<td><asp:button runat='server' OnClick='selectMember' CssClass='btn btn-default' style='display:none' value = '"
                    + btnValue.ToString() + "' id= 'btnMembGrid" + counter.ToString() +  "'/></td>");
                html.Append("</tr>");
            }

```

I attempted to accomplish this task by placing a hidden `<asp:Button/>` in each row and then adding a corresponding `onclick` attribute to each `<tr>` tag

This is how the generated html looks like in the dev console 

[![enter image description here](https://i.stack.imgur.com/gpe9n.png)](https://i.stack.imgur.com/gpe9n.png)

However when I attempt to click the row I get the following error message 

[![enter image description here](https://i.stack.imgur.com/83TKB.png)](https://i.stack.imgur.com/83TKB.png)

I am having a hard time understanding what exactly I'm doing wrong. I'd appreciate some input, or possibly even an alternative approach.