473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

LinkButton added at runtime - and fetch it!

All,

I've been trying to get this question answered before and I got some hints,
but nothing that really fit my needs.

Here's what I'm aiming at:

I create x number of LinkButton at run-time in a UserControl, no probs.

However, when I click on on of them, I want to fetch which one of them that
was clicked and a value which is assigned via lnkbtn.ID (I could also take
the .text attribute, but I prefer the .ID).

Here is my simple sample code:

For a As Integer = 0 To 5

Dim lnkbtn As New LinkButton
lnkbtn.ID = "lnkbtn_" & CType(a, String)
lnkbtn.Text = "Linkbutton " & a

Me.Controls.Add(lnkbtn)

Next

So far so good. Now, how do I write a procedure that fetch the button
clicked? I want to get the text or the ID from that button.

I've been on Google, a number of forums and MSDN but can't find anything
that really explains this.

I'm writing everything in VB. One suggestion I got was to use a DataList,
but that doesn't really work for me.

Please note:
I DON'T add anything in design-time.

All help appreciated!

Thanks,
Fredrik
Nov 18 '05 #1
1 1541
Instead of this approach, why not set this information as part of the
CommandText. You can then wire-up a Command event to catch this instead of
the Click event.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Fredrik Rodin" <ro***@dacsa.net> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
All,

I've been trying to get this question answered before and I got some hints, but nothing that really fit my needs.

Here's what I'm aiming at:

I create x number of LinkButton at run-time in a UserControl, no probs.

However, when I click on on of them, I want to fetch which one of them that was clicked and a value which is assigned via lnkbtn.ID (I could also take
the .text attribute, but I prefer the .ID).

Here is my simple sample code:

For a As Integer = 0 To 5

Dim lnkbtn As New LinkButton
lnkbtn.ID = "lnkbtn_" & CType(a, String)
lnkbtn.Text = "Linkbutton " & a

Me.Controls.Add(lnkbtn)

Next

So far so good. Now, how do I write a procedure that fetch the button
clicked? I want to get the text or the ID from that button.

I've been on Google, a number of forums and MSDN but can't find anything
that really explains this.

I'm writing everything in VB. One suggestion I got was to use a DataList,
but that doesn't really work for me.

Please note:
I DON'T add anything in design-time.

All help appreciated!

Thanks,
Fredrik

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Vi | last post by:
Hi, I'm trying to dinamically add LinkButton Controls to a web form. I do something like: for(i=1;i<=someVariable;i++) { LinkButton PageLink = new LinkButton(); PageLink.CommandName =...
4
by: Fueled | last post by:
Hi everyone! I've made quite a lot of research on this, and I've tried a couple of proposed solutions. Nothing has worked for me, but I feel there's not much I'm missing. So I'm turning to this...
2
by: egholm | last post by:
Hi The code below is adding a dynamicly created LinkButton to a placeholder control. When I click the LinkButton it should call attLink_Click(), but it dosen't happen. What is wrong? Please...
7
by: Alex Maghen | last post by:
I have a DataGrid control with a LinkButton command column that deletes the row. What I want to do is set it up so that there's a client-side Confirm alert BEFORE the actual Delete command gets...
13
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his...
0
by: OceanBreeze | last post by:
I have added a LinkButton to a table cell programmatically inside the Page_Load method. I also added a custom event to that link button. The same custom event is valid for all the link buttons. The...
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
6
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the...
5
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.