473,396 Members | 1,816 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,396 software developers and data experts.

Dynamic LinkButton Control

RSB
Hi Everyone,

I have a collection of items and i am generating a Dynamic Table based on
this Collection and i am also adding a Remove Linkbutton at the End for Each
Row. I have created a function called GenerateList and i call this in the
OnPreRender
Now every thing is fine but i am not able to Capture the Event for the
"Remove This"
all i want to do is remove the selected item from the collection..
Please help

Here is the COde..

public void GenerateList(MyCollection myCollection ) {

Table tblMain = new Table();
TableRow row = new TableRow();
TableCell cell = new TableCell() ;
addGridTableCell(row, " Student#",3,"#AAAADD","SmallDatalabel");
addGridTableCell(row, "Name",8,"#AAAADD","SmallDatalabel");
addGridTableCell(row, "Address",50,"#AAAADD","SmallDatalabel");
addGridTableCell(row, "Phone",13,"#AAAADD","SmallDatalabel");
tblMain.Rows.Add(row);
int i=0;
myCollectionItem s;
LinkButton LinkBut ;
foreach( System.Collections.DictionaryEntry e in myCollection ) {

s = (myCollectionItem) e.Value;

i++;
row = new TableRow();
addGridTableCell(row, i.ToString(),3,"#FFFFFF","");
addGridTableCell(row, s.Name.ToString () ,8,"#FFFFFF"," ");
addGridTableCell(row, s.Address.ToString(),50,"#FFFFFF"," ");
addGridTableCell(row, s.Phone.ToString () ,13,"#FFFFFF"," ");

cell = new TableCell() ;
cell.Width = Unit.Percentage(8.0);
cell.BackColor = Color.FromName("#FFFFFF");
LinkBut = new LinkButton();
LinkBut.ID = e.Key.ToString();
LinkBut.Text = "Remove this";
LinkBut.Click += new System.EventHandler(this.LinkBut_Click);
cell.Controls.Add(LinkBut);

row.Cells.Add (cell);

tblMain.Rows.Add(row);
}
}
public static void addGridTableCell(TableRow row, string cellText, double
cellWidth, string bgColor, string clsName){
TableCell cell = new TableCell() ;
cell.Text = cellText;
cell.Width = Unit.Percentage(cellWidth);
cell.BackColor = Color.FromName(bgColor);
cell.CssClass = clsName;
//cell.Wrap = false;
row.Cells.Add (cell);
}
Nov 18 '05 #1
1 2494
"RSB" <rs*****@hotmail.com> wrote in message
news:Ht*****************@news.cpqcorp.net...
Hi Everyone,

I have a collection of items and i am generating a Dynamic Table based on
this Collection and i am also adding a Remove Linkbutton at the End for Each Row. I have created a function called GenerateList and i call this in the
OnPreRender
Now every thing is fine but i am not able to Capture the Event for the
"Remove This"
all i want to do is remove the selected item from the collection..


Had you considered using a DataGrid instead of your dynamic table? You could
use a HyperLinkColumn for your Remove link and handle the ItemCommand event
of the DataGrid to tell you which Remove link had been clicked.

Alternatively, could you generate your table earlier than PreRender? Then
you'd be able to use the Click event of your LinkButton.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

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

Similar topics

4
by: sef | last post by:
i have a server-side script that executes this: linkbutton1.Attributes.Add("onClick", "linkClicked();"); the client-side code has an html image control <img id="image1"> the client-side...
0
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to...
0
by: Pat Sagaser via .NET 247 | last post by:
I'm trying to add LinkButtons to a Repeater control using adynamic template. The docs state that you should be able tobubble the click event to the containing Repeater. There areplenty of examples in...
1
by: Peter Wu | last post by:
Hello Group, I create a class that inherits from the System.Web.UI.WebControls.DataGrid class. Basically, what I want to do is to dynamically add a Table that contains some numbers for paging....
2
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has...
2
by: cindy | last post by:
I have a web form with 3 links, depending on which link is clicked a user control loads, page1.ascx,page2.ascx,page3.ascx page1.ascx does a search, uses 3 asp:dropdownlists with viewstate true...
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...
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...
4
by: marty | last post by:
Having trouble creating a dynamic pagertemplate. I want it like this "Prev 1 2 3 4 Next". The numerically portion being the dynamic part based on the record count. I can generate it, but can't...
0
by: axxon | last post by:
hi, I am having a huge problem here! the scenario is i am trying to create dynamic accordion Panes to a accordion control inside a tab panel in a content page. It works just fine in a regular...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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
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...

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.