I have a grid in asp.net, inside the asp.net i am binding data as linkbutton when clicking on link button I need to call a method in code behind. the attached event is not woking in my code. how i can solve this?
my code is similar like this,
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton link = new LinkButton();
link.Text = e.Row.Cells[0].Text;
link.CommandArgument = "Hello";
link.Click += new EventHandler(this.onLinkClick);
e.Row.Cells[0].Controls.Add(link);
}
}
protected void onLinkClick(object sender, EventArgs e)
{
LinkButton btn = (LinkButton)(sender);
string value = btn.CommandArgument;
TextBox1.Text=value;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…