This is mainly a sharepoint webpart development issue but after 4 days
of posting I haven't had even one answer so I figured I'd post here and
see if anyone might spot something. There might be something in
creating an array of objects I've missed or maybe someone in the group
has done some sharepoint development so, here goes.
I'm attempting to add an array of linkbutton items to a webpart, the
items get added, show on the page, but the click event of the buttons
never gets called.
Adding a single link, not in an array works just fine.
Whats the difference? And why wont the array eventhandler get called?
here's the code bit:
protected LinkButton[] codeIDLinks = new LinkButton[20]; <--real
protected LinkButton link = new LinkButton(); <--test one
// the real one i'm attempting
for(int i=0;i<codeIDLinks.Length;++i) {
codeIDLinks[i] = new LinkButton();
codeIDLinks[i].Command += new CommandEventHandler(this.LTCCommand);
codeIDLinks[i].Text = i.ToString(); <--this works and shows the #'s 1-20
Controls.Add(codeIDLinks[i]); // adds the control to sharepoint
}
// the test one, this works
link.Command += new CommandEventHandler(link_Command);
link.Text = "Text";
link.ID = "Text1";
Controls.Add(link);
The array version works, shows the #'s 1-20 and makes them links
complete with javascript postback (LEFT$....) but the click event
*never* gets called. The single declaration one works just fine.
So, do I have to make 20 of these damm link buttons manually and 20
assignments or am I missing some galactic thing in sharepoint using
arrays like this?