R
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);
}
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);
}