views:

194

answers:

2

Ok, i have a gridview and on page load, i dynamically add a column to it that contains a link control. this link control has a onclick event associated with it so that when its clicked, i want to do some processing. Now I have noticed that if I just bind the grid the first time (i.e. if(!IsPostBack) and have enableviewstate for the grid to be true, clicking the link in that column, doesnt trigger the onclick event. But if I bind the grid on every postback, everything seems to be working..does anyone know the reasoning behind it?

+1  A: 

It happens because you're dynamically adding the column, so on every postback the column has to be created. What you may want to do is to look at Creating a Custom Column.

CAbbott
A: 

Hi,

May be creating the row Id solves your problem. Check out this link and the post marked as answer.

http://forums.asp.net/p/1471128/3408069.aspx#3408069

Regards Vinay

Vinay