Hello,
I think I have understood your problem:
You retrieve a list of buttons from a database accordingly to a user's profile
You display said list of buttons on some user page
You want to wire the right events handling to the buttons
My solution would be to store a method's name in the Button.Tag property rather than a sequence number. In that way you can use reflection and call the apropriate method for the button being clicked:
void button_click(object sender, EventArgs e)
{
Button btn = sender as Button;
if (!btn == null)
{
this.GetType().InvokeMember(this, btn.Tag);
}
}
Well, my use of reflection is a bit rusty but that sample should get you back to work.