views:

45

answers:

1

I have <asp:GridView /> control on the form and <asp:LinkButton /> when there is no any data in GridView, generated HTML of LinkButton looks like that

<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$contolPanel$ctl00$ctl00$addNew','')" id="ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl00_addNew">
    <strong class="CmsButRight light">Add new</strong>
</a>

and all is working, but when I set the data of the GridView via the DataSource property and invoke the DataBind() method, the generated code looks like that

<a href="javascript:__doPostBack('ctl00$addNew','')" id="ctl00_addNew">
    <strong>Add new</strong>
</a>

As you can see it generated wrong ID of the LinkButton control and the OnClick handler does not invoked on PostBack.

A: 

It can be a problem in layout. Try to set LinkButton before GridView and check that problem is still exists.

Rover
2 RoverLinkButton located before GridView
sound
Could you post the aspx code?
Rover