Multiple dynamically added link buttons


F

Fredrik Rodin

All,

I have a sub that generates a number of link buttons depending on the number
of records returned by the SQL.

Do While dReader.Read

Dim tr As New TableRow
Dim td As New TableCell
Dim lnkbtn_grp1 As New LinkButton

lnkbtn_grp1.Text = CType(dReader("GROUP_NAME_1"), String)

td.Controls.Add(lnkbtn_grp1)
tr.Cells.Add(td)
Table1.Rows.Add(tr)

Loop

This create a table with a <tr> for each group name found in the DB. Now,
when I click on the button I want to fetch the value of that button. Please
note, I would like to have a different value than the text.

I've been on Google but can't really find any matching code.

Anybody can helP???

Thanks in advance,
Fredrik
 
Ad

Advertisements

M

Marina

I would recommend using a datalist. You will end up with virtually no code
as far as creating elements is concerned. You also won't have to
re-retrieve your data every time the page loads, as datalist will maintain
everything through viewstate.

The datalist also has the ItemCommand event for when a button inside it was
clicked.
 
Ad

Advertisements

F

Fredrik Rodin

Thanks Marina!

That should work. I'll check that out. The thought never came to my mind
really...;-)

/Fredrik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top