ASP.net adding buttons to rows of an unbound GridView
Posted on 2012-09-20
I have an unbound GridView: gvCompanies, which I populate as follows:
SQLQuery = "EXEC AdmListCompaniesForNewsArticle " & Request.QueryString("neid")
cmdQuery = New SqlCommand(SQLQuery, DBCon)
rdrResults = cmdQuery.ExecuteReader
dtTable = New DataTable()
Do While rdrResults.Read
drRow = dtTable.NewRow
drRow("Name") = rdrResults!name
gvCompanies.DataSource = dtTable
I would like to add a button to each row, which will delete that entry in the table.
The button must act within the code behind, rather than going to a new page, as there is likely to be other unsaved fields on the page.
Can I do this with this structure, and if so, how?