Problem adding dynamic LinkButton[] Array with event to a page

M

Martin Strojek

Hi,

i got a problem with adding a LinkButton array with one event for all
to a webpage. I read some posts about that here but some are not
answered and some have no solution for me.

1.
I added a LinkButton Array at the top of the page as member variable:

private LinkButton[] LinkButtonEdit;

2.
So that the events will be registered on every page load i created
a method private void InitializeLinkButtonEditEvents() wich is called
in the
standard Page_Load Method.

It contains the following code:
dbimages --> Create dbimages DataTable from some database rows.

LinkButtonEdit = new LinkButton[dbimages.Rows.Count]; int rowcount =
0;
foreach (DataRow row in dbimages.Rows )
{
LinkButtonEdit[rowcount] = new LinkButton();
LinkButtonEdit[rowcount].Text = "Edit";
LinkButtonEdit[rowcount].ID = "LinkButtonEdit_" +
row["img_id"].ToString();
LinkButtonEdit[rowcount].Click += new
System.EventHandler(this.LinnkButtonEdit_Click);

rowcount++;
}

3.
I add a table with the entries of the above datatable to the page
wich is showing some of the data and add the link button to each line

cellopt.Controls.Add( LinkButtonEdit[rowcount] );


4.
I added some Event Method

private void LinkButtonEdit_Click(object sender, System.EventArgs e)

with some debug output to a Label


The problem is: the event is not be fired - the page reloads but
i can't see my message. The link commands in the page-source looks
good.
What went wrong? Any suggestions? I have a working page like that
where the only difference is that i only got a char for the
buttonid's.


Thanks for some comment about that and best regards.

Martin Strojek
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top