469,651 Members | 1,676 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,651 developers. It's quick & easy.

Multiple dynamically added link buttons

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
Nov 18 '05 #1
2 1080
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.

"Fredrik Rodin" <ro***@dacsa.net> wrote in message
news:uV**************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #2
Thanks Marina!

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

/Fredrik

"Marina" <so*****@nospam.com> wrote in message
news:ea*************@tk2msftngp13.phx.gbl...
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.

"Fredrik Rodin" <ro***@dacsa.net> wrote in message
news:uV**************@tk2msftngp13.phx.gbl...
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


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bob | last post: by
1 post views Thread by AndrewMBaldwin | last post: by
6 posts views Thread by Bjorn Sagbakken | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.