1

The problem is simple: In a ASP.NET GridView, if the property e.Row.Parent.ClientID is used in the RowDataBound event, .NET generates another identifier for the GridView, and if you had javascripts in your page that used the ClientID for the GridView, they wont work.

To replicate the problem, you have to create a WebForm with one GridView, one Client HTML Button has to access the GridView identifier like this:

<input id="Button1" type="button" value="Test" onclick="alert('The next message does not have to be null: ' + document.getElementById('<%=gridViewTest.ClientID %>'))" />

If in gridViewTest_RowDataBound you don't use the e.Row.Parent.ClientID property, everything will be fine, but if you use e.Row.Parent.ClientID for some purpose, .NET will generate another ID for the GridView and the HTML Button will not work anymore.

Is that the expected behavior, or it is a bug? Has anyone had this problem?

Thanks

1 Answers1

0

That's because e.Row.Parent is not the GridView (gridViewTest in your case), is a children of the GridView.

Going one step up should do the trick, so just add a .Parent and you are good to go

e.Row.Parent.Parent.ClientID
Enrique Zavaleta
  • 2,098
  • 3
  • 21
  • 29