I have a dynamically created action button within a method. I've assigned an ID to the button, but I need to open a modal when the button is clicked. I'll then need to pass the button ID to the modal in order to retrieve the data. How can I open a modal within this method?

private static List<Details> LoadData()
        List<Details> infoObjs = new List<Details>();

            using (SqlConnection con = new SqlConnection(cs))
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                    Details infoObj = new Details();
                    infoObj.CommentsID = rdr["COMMENT_ID"].ToString();
                    infoObj.Comments = rdr["COMMENT"].ToString();
                    infoObj.Status = rdr["STATUS"].ToString();
                    infoObj.Date = rdr["DATE"].ToString();

                    infoObj.Action = "<a class='btn btn-warning' ID=" + infoObj.CommentsID + "> <i class=\"fas fa-pencil-alt\" aria-hidden=\"true\"></i></a>";
                    //This button needs to open a modal.
        return infoObjs;

Related posts

Recent Viewed