This is application i am doing in c# web application
I am creating link buttons dynamically as below.
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
LinkButton ln = new LinkButton();
ln.Text = ds.Tables[0].Rows[i].ItemArray[0].ToString();
ln.ID = ds.Tables[0].Rows[i].ItemArray[1].ToString();
divonlne.Controls.Add(ln);
divonlne.Controls.Add(new LiteralControl("<br/>"));
}
my click event is as follows
ln.Click += new EventHandler(Clicked);
In my click event i am getting the linkbutton text and Id as follows
protected void Clicked(object sender, EventArgs e)
{
LinkButton lno = sender as LinkButton;
Session["Toname"] = lno.Text;
Session["idto"] = lno.ID;
}
But this is firing only when the last link button is clicked.
Can anyone help me out?
You already wrote how you subscribe the
ClickEvent, but in your sample i cant see it.Maybe you subscribe on the wrong place. This works…