Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
Only page 1 works fine in UltraWebGrid
posted

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:

Sub ViewButton_Click(ByVal sender As Object, ByVal e As CommandEventArgs)

Try
   Dim button As ImageButton = DirectCast(sender, ImageButton)
   Dim id As Object = Me.UltraWebGrid1.Rows(Integer.Parse(button.CommandArgument)).Cells.FromKey("ID").Value
   Response.Redirect(
"report.aspx?fid=" & id.ToString(), False)
Catch ex As Exception

End Try
End 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:

<igtbl:TemplatedColumn Key="ViewItem" Width="20px" AllowGroupBy="No"

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 -

 

 

Parents Reply Children
No Data