S
Shawn Zavoda
I have read through these groups repeatedly, but I keep missing this
topic if it has already been posted....
I have a Table Control where on each row I dynamically add a
LinkButton to "Edit" something. For each LinkButton, I would like to
know what the ID is of the item to be edited by assigning it to the
CommandArguement.
The Control is re-created in the OnInit() override and placed in a
PlaceHolder Control override to allow the OnClick event to raise.
This is of course before the base.OnInit() is called...
However, how can I access the CommandArgument property in the event
handler once it is there? The code below gives me an empty string.
Up till now, as a work around, I have created a hidden text HTML
control and filled it with a MouseDown event from the LinkButton with
the ID that is being fired - this is very ugly and seems clumsy way to
do this.....
Any ideas?
Thanks!
Shawn
Sample of what I am trying to do...
private void Page_Load(object sender, System.EventArgs e)
{
lb = new LinkButton();
lb.Text = "Edit";
lb.ID = "btnEdit";
lb.Click += new EventHandler(btnClose_Click);
lb.CommandArguement = myID.ToString ();
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.Controls.Add (lb);
tr.Cells.Add (tc);
this.Table.Rows.Add (tr);
}
override protected void OnInit(EventArgs e)
{
LinkButton lb = new LinkButton();
lb.ID = "btnEdit";
lb.Click += new EventHandler(btnEdit_Click);
this.PlaceHolder1.Controls.Add (lb);
InitializeComponent();
base.OnInit(e);
}
private void btnEdit_Click(object sender, System.EventArgs e)
{
LinkButton lb = (LinkButton) sender;
int myID = Convert.ToInt32 (lb.CommandArguements);
}
topic if it has already been posted....
I have a Table Control where on each row I dynamically add a
LinkButton to "Edit" something. For each LinkButton, I would like to
know what the ID is of the item to be edited by assigning it to the
CommandArguement.
The Control is re-created in the OnInit() override and placed in a
PlaceHolder Control override to allow the OnClick event to raise.
This is of course before the base.OnInit() is called...
However, how can I access the CommandArgument property in the event
handler once it is there? The code below gives me an empty string.
Up till now, as a work around, I have created a hidden text HTML
control and filled it with a MouseDown event from the LinkButton with
the ID that is being fired - this is very ugly and seems clumsy way to
do this.....
Any ideas?
Thanks!
Shawn
Sample of what I am trying to do...
private void Page_Load(object sender, System.EventArgs e)
{
lb = new LinkButton();
lb.Text = "Edit";
lb.ID = "btnEdit";
lb.Click += new EventHandler(btnClose_Click);
lb.CommandArguement = myID.ToString ();
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.Controls.Add (lb);
tr.Cells.Add (tc);
this.Table.Rows.Add (tr);
}
override protected void OnInit(EventArgs e)
{
LinkButton lb = new LinkButton();
lb.ID = "btnEdit";
lb.Click += new EventHandler(btnEdit_Click);
this.PlaceHolder1.Controls.Add (lb);
InitializeComponent();
base.OnInit(e);
}
private void btnEdit_Click(object sender, System.EventArgs e)
{
LinkButton lb = (LinkButton) sender;
int myID = Convert.ToInt32 (lb.CommandArguements);
}