Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic LinkButton Control

Reply
Thread Tools

Dynamic LinkButton Control

 
 
RSB
Guest
Posts: n/a
 
      07-27-2004
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);
}


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      07-27-2004
"RSB" <> wrote in message
news:HtyNc.6676$...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
placement of dynamic control depends on VALUE of dynamic control Larry Bud ASP .Net 1 01-10-2007 10:07 PM
User Control and dynamic LinkButton problem Fueled ASP .Net 4 11-10-2005 05:15 PM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net 3 09-08-2005 09:41 AM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net Datagrid Control 1 09-08-2005 08:44 AM
Adding dynamic LinkButton to dynamic table =?Utf-8?B?QkxpVFpXaU5H?= ASP .Net 0 07-27-2005 12:21 AM



Advertisments