Hello, I create some dynamic LinkButtons in a grid that acts as a timebook, the individual "times" - the buttons can be clicked and that should call the method (editGrid).
I try to do this in the admin_pages.aspx.cs file.
Creating a similar button from code in for example in the page load works fine. But it does not work in the method "buildGui".
Can anyone see why?
VulpesPosted May 28, 2011, 6:00 AM
Dynamic controls will need to be recreated each time the page is loaded, including on postbacks, which currently will not be the case.
Mats APosted May 28, 2011, 8:15 AM
Sam HobbsPosted May 28, 2011, 5:32 AM
Thank you for the small peice of code. That looks okay as far as I can see. I don't know what "cell" is though.
I have a suggestion. I am not saying this to make a quick reply; this is actually what I would do.
I would create a test project and I would try to create the smallest possible peice of code that reproduces the problem. Unfortunately that might not be practical in this situation since you cannot be certain that just because the test does not work that it is not working for the same reason. So another possibility is to copy the relevant portions of the actual project and then strip it down to the bare minimum that re-creates the problem.
If you could just provide some guidance to what to look at in that big project, then people are more likely to look at it.
Mats APosted May 28, 2011, 3:43 AM
No answers yet, and I still cannot understand this, so here is some code.
Hopefully someone can explain this to me, what am i doing wrong?
The user pushes a button, and then I create an table and use the following code to add a button:
LinkButton _button = new LinkButton();
DateTime buttonText = Convert.ToDateTime(dr.ItemArray[i].ToString());
_button.Text = buttonText.ToShortTimeString();
_button.ID = "control_" + controlid++.ToString();
_button.CommandArgument = dr.ItemArray[i].ToString();
_button.Command += new CommandEventHandler(_button_Command);
cell.Controls.Add(_button);
As the user click on the linkbutton I want the _button_Command method to be called, and it looks like this:
public void _button_Command(object sender, CommandEventArgs e)
{
int test = 0;
}
It is never called, any ideas why?
Mats APosted May 15, 2011, 5:26 AM
That method is only called as the user pushes a button on my page.
Suthish NairPosted May 15, 2011, 5:02 AM