asp.net - .net development dynamically created controls need their own methods -


I'm pretty sure that with the dynamic creation of almost all programming buttons in .NET, they have gone to the same issues. / P>

Example Scenario ..

I have a button in a gridview and a gridview field, usually by using Visual Studio, you can easily grab click event of the button Although, since these buttons are dynamically created, they can catch It is not easy I'll do the best way to grab the click program was curious button.

I think it's possible using dopostback; However, I am not sure how to implement it or I tried because I have also read the Doopostback method, it is not very good to use. Why is it like this?

In Gridview, an event is called. Place an event handler on it:

  Rowdadabad + = new event heredollar (line-bound);  

Now inside that function, you will use FindControl to find the button and add a handler:

  function LineBound (Object Sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) as the button {var b = e.row.FindControl ("btn"); B Click + = new event here handler (handlatinclick); }}  

Comments