0

I want a delete button in every HTML table row in client side.How can i place an asp.net button in table cell so that i can delete a particular row from its ID.

        foreach (DataRow row in data.Rows)
        {

            ID = row["Mem_id"].ToString();
             Name = row["Mem_Name"].ToString();
             Email = row["Mem_Email"].ToString();
             Designation = row["Mem_Designation"].ToString();
             Depart = row["Mem_Dept"].ToString();
             Phone = row["Mem_Phone"].ToString();
             MemType = row["Mem_Type"].ToString();
             image = "<img width=100 height=100 src=/imagesz/" + row["Mem_Image"].ToString() + ">";

             tbl.Text = tbl.Text + "<tr><td>" + ID + "</td><td>" + Name + "</td><td>" + Email + "</td><td>" + Designation + "</td><td>" + Depart + "</td><td>" + Phone + "</td><td>" + MemType + "</td><td>" + image + "</td><td>I WANT TO ADD ASP.NET DELETE BUTTON HERE</td></tr>";


        }


    }
4
  • 1
    What is tbl? What do you mean by "delete a particular row from its ID"? Commented May 23, 2018 at 0:40
  • tbl.text is actually a asp.net label. and i want delete button in table cell so that i can delete any row from table records. Commented May 23, 2018 at 0:42
  • uh, how did you create the table? is it by string concatenation? if so, its a bad idea.. try your luck with Repeater. Commented May 23, 2018 at 0:44
  • yes i know ! thank you for your answer.. Commented May 23, 2018 at 0:45

2 Answers 2

1

You cannot add a server-side control (such as an ASP:Button) by putting it into the markup. There is much more to a control than its HTML.

To add buttons for each row, I suggest you abandon your approach of constructing an HTML string, and instead use either a Repeater or a GridView. If you follow the links it'll show you how to add a button to each.

Sign up to request clarification or add additional context in comments.

Comments

0

Could you please more context? I think is a bit confusing trying to help with an approach. So far, John Wu Has provided a good answer. This can be address by using asp controls.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.