Please make some change in your code according to below code block...
Try this:
<pre lang="c#">
while (reade.Read())
{
Session["View"] = Convert.ToString(reade["View"]);
//Button Add = (Button)PreviousPage.FindControl("Button2");
if (Session["View"].ToString() == "Y")
{
LinkButton la=new LinkButton();
la.Text = "Checkout";
//a.ID="link1";
la.Click += new System.EventHandler(LinkButtonTest_Click);
Panel1.Controls.Add(la);
Panel1.Controls.Add(new LiteralControl("<br />"));
//tr2.Visible = true;
}
else .....
}
Instead of this:
while (reade.Read())
{
Session["View"] = Convert.ToString(reade["View"]);
}
if (Session["View"].ToString() == "Y")
{
LinkButton la=new LinkButton();
la.Text = "Checkout";
la.Click += new System.EventHandler(LinkButtonTest_Click);
Panel1.Controls.Add(la);
Panel1.Controls.Add(new LiteralControl("<br />"));
}
else .....
I think it's work fine for you because "While" loop read multiple value from database then generate multiple control for you. If you write control generation code out side of "While" loop ti's generate only one control for you.