Hello,
I use the UltraWebgrid for CLR2.0 in Visual Studio 2008 with IG version 2008 Vol.3.The grid has 3 columns with 3 imageButtons and the normal data columns. In my Click event of one of these imageButtons I redirect to the view page with the fully detailed record information on a detailsView:
End TryEnd Sub
This works fine, till I go to the 2nd page via the pager. ( have 65 records, and on every page 10 records) When I click on the View Button, I receive an error on the line in the ViewButton_Click Event. The message is: 'Object reference not set to an instance of an object.'
When I debug into the code, I see that the button.CommandArgument equals 12 which is my Row Index, that is right. Via this index I retrieve the choosen Masterkey ID which works fine on page 1, only. The problem is I think, because the CommandArgument = 12 and row 12 doesn't exist on page 2. It should be row 2 or 1 when it is zero based. So what can I do about this? There should be some other way to get the ID column value I think.The imageButton in markup looks like:
AllowRowFiltering="False">
<CellTemplate>
<asp:ImageButton runat="server" ID="ViewButton" CommandName="View" OnCommand="ViewButton_Click" CommandArgument="<%# Container.Cell.Row.Index %>" ImageUrl="../images/icon_view.gif" ToolTip="View Audit Report" />
</CellTemplate>
I hope that somebody can help me out. Thanks in advance!Best regards,
- AJ -
Hello Alex, thank you for your fast reply. Yes the Index is not reliable as I found out. I solved the problem today with using:
CommandArgument="<%# Container.Cell.Row.DataKey%>" and not via the Index:CommandArgument="<%# Container.Cell.Row.Index%>"
And that was all!
The only issue I still have, is that loading the grid is not so fast. I have only 65 records and 10 records per page. So only 7 pages. Even on my local server I have to wait a few seconds. The property EnableInternalRowsManagement is set to False. I assume that only 10 records are loaded in the viewstate or all rows to enable the paging function?
Maybe you have still some suggestion for this issue?
Thanks in advance.
-AJ_
Hello Alex, thanks for the answer. No I need this buttons, because my client wants to see a picture and not a button. But do you mean that the grid is slower now because I use this ImageButtons?
-AJ-