1
Answer

Add click event to dynamically creatd linkbutton in gridview

monica singh

monica singh

8y
218
1
Hello
I am working on application which requires to generate dynamic columns in gridview and then bound with linkbutton.
this much is done , but i have to add click event to link button but event is not fired .
below is code which i have tried.
below code is inside rowbound event of gridview.
 
foreach (DateTime dt in days)
{
LinkButton lb = new LinkButton();

lb.ID = "lb" + i;
lb.Attributes.Add("runat", "server");
lb.Text = r1[dt.Date.ToString("dd-MM-yyyy")].ToString();
lb.CommandName = "UpDate";
lb.Command += lb_Command;
// lb.OnClientClick += new EventHandler(onLinkClick);
// lb.Click += new System.EventHandler(onLinkClick);
// lb.DataBinding += lb_DataBinding;


row.Cells[i + 2].Controls.Add(lb);
i++;
if (dt.Date <= System.DateTime.Today)
{
lb.Enabled = false;
}
} 
Answers (1)