Unable to fire LinkButton_Click Event

82 Views Asked by At

Actually,I'm Dynamically generating Controls and adding them to a Panel. Now,I'm showing my Records Count in a LinkButton and on LinkButton_Click,I'm showing the actual Records.
On the Page_Load,the data is Binding Perfect and all the controls gets added to the Panel.
But after clicking the LinkButton,It is not entering the LinkButton_Click event.
I'm getting an error after the Page_Load event like :

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

It doesn't even enter into Catch Block.

My LinkButton code :

LinkButton lblCount = new LinkButton() { ID = "lblCount" + j + i + 1, Text = ans_count.ToString() };
//lblCount.EnableDefaultAppearance = false;
lblCount.EnableTheming = false;
lblCount.ForeColor = Color.Black;
lblCount.Font.Bold = true;
lblCount.Font.Underline = true;

string strval = String.Format("{0}~{1}~{2}", tempid, questionid, answerid);
lblCount.CommandArgument = strval;
lblCount.Click += new EventHandler(this.LbtnCount_Click);
Panel_Answers.Controls.Add(lblCount);
1

There are 1 best solutions below

0
On BEST ANSWER

i think you need to add your controls in OnInit Event not page load, give it a try