BulkEditGridView + InsertRows + Current Row Index by Container.DataItemIndex

Topics: Developer Forum
Apr 8, 2008 at 9:08 AM
I am using the GridView for editing multiple lines. Basically the whole thing works fine. It displays the lines from the datasource plus a certain number of insert lines. Perfect. But there is one think which I could not solve till now.

Following, I have a column with an image button. If I click on the button I call a javascript function. I want to provide the current row index to the function. It looks like this:

<controls:BulkdEditGridView ID="GridView" runat="server" DataSourceID="ObjDataSource" AutoGenerateColumns="false" ...>
<Columns>
...
<asp:TemplateField>
<itemtemplate>
<img id="imgBtn" alt="Some Text" src="/at.gv.noe/Images/Delete.gif" onclick="DoSomething(<%# Container.DataItemIndex + (GridView.ShowHeader ? 1 : 0) %>)" />
</itemtemplate>
</asp:TemplateField>
...
</Columns>
</controls:BuilEditGridView>

So If I click on line 2 the function is called with parameter value 2. That is want I want to have. But it does not work if I click on an Insert Row. That means for instance I set the insertrowcount to 5 and I get 5 additional lines. If I click on one of the insert lines the Container.DataItemIndex always returns something like undefined. But never the actual RowIndex.

How can I solve this?

br
Thomas