473,787 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Tex t = 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 1156
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.ne t> wrote in message
news:uV******** ******@tk2msftn gp13.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.Tex t = 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******** *****@tk2msftng p13.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.ne t> wrote in message
news:uV******** ******@tk2msftn gp13.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.Tex t = 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1638
by: Bob | last post by:
I have a requirement to show a label and x number of buttons in all of the pages. So i decided to write a Base Page class and added code for dynamically adding the label and buttons. For the buttons i have added the handlers. Finally added the label and buttons to a place holder. When page is rendered i am able to see the label and buttons. but when i click the buttons events are not firing. i found two problems. First one is when i...
2
1949
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status) to determine what options should be available for this particular item (which is an issue... small issue tracking system). Each of these options is an action that may be performed on the issue and I am dynamically creating LinkButtons for each...
1
1502
by: AndrewMBaldwin | last post by:
Ok, this is going to be a long post, so I apologize in advance, but if it was an easy question I would have probably found an answer somewhere out here by now... The short story of this is that I am creating a "process framework" that allows for common web controls to be linked together in a procedural fashion, and will also allow for code to be added to these controls (IE New button events, etc). I have basically created a static...
3
6255
by: akki | last post by:
I create link buttons dynamically in the code and give them IDs through which I can distinguish them.I want to know how to create a single event handler for all the link buttons that I create The event handler should also be able to identify which link button was clicked....(I am using VB as the code behind language). Please reply....
9
3194
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will load with different data (locations, departments, etc.).
1
6530
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page. I am able to call values from file in my jsp page. But as dynamic values can be any in no...
0
4074
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page.But as dynamic values can be any in no i don't know how could i populate all those in my jsp...
6
1497
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired subroutine on postback. To me it seems like the button click event looks for a client script instead of going to the aspx codepage and execute the sub there. The same thing happens with textboxes, where I programatically add
3
8527
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at run time and the number may vary, we can't statically tie to the event to a control. I'm assuming I need to dynamically add event handlers at run time, and that one method could act as the event handler, with unique event args being created for...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.