jm1234
June 5th, 2006, 04:39 PM
Hi,
I have a gridview with paging enabled (10 recs per page) that is binded to an arraylist of my customer object (this is a custom object I wrote myself). I have three columns - Delete (which contains a Delete linkbutton - not the one that is defautly in the gridview, but a linkbutton in a template column), CustomerID, CustomerName. The paging works fine, but when I delete a row from any other page but page 1, it tries to delete a record from page one, not the record I've clicked on in say page 2. Why would this be happening?
In the RowCommand event from clicking the Delete button, I have the following:
If e.CommandName = "DeleteCustomer" Then
vCustomerID = e.CommandArgument 'should return the customer ID
DeleteCustomer(vCustomerID)
End If
...the problem is e.CommandArgument is returning the customer ID from the same row index from the first page. So again, what could cause this?
Thanks!!!!!
I should add this too, here's my gridview:
<asp:GridView runat="server" ID="UserCustomerGrd" DataKeyNames="CustomerID"
AllowPaging="true" PageSize="10" AutoGenerateColumns="false"
CellSpacing="0" CellPadding="3"
<Columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate><asp:LinkButton ID="DelBtn" OnClientClick="javascript:return confirm('Are you sure you wish to delete?')" CommandArgument='<%#Eval("CustomerID")%>' CommandName="Delete" runat="server">Delete</asp:LinkButton></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CustomerID" HeaderText="Customer ID"/>
<asp:BoundField DataField="Name" HeaderText="Customer Name"/>
</Columns>
<PagerSettings Mode="NumericFirstLast" LastPageText="Last" FirstPageText="First" />
<PagerStyle HorizontalAlign="Center" />
</asp:GridView>
I have a gridview with paging enabled (10 recs per page) that is binded to an arraylist of my customer object (this is a custom object I wrote myself). I have three columns - Delete (which contains a Delete linkbutton - not the one that is defautly in the gridview, but a linkbutton in a template column), CustomerID, CustomerName. The paging works fine, but when I delete a row from any other page but page 1, it tries to delete a record from page one, not the record I've clicked on in say page 2. Why would this be happening?
In the RowCommand event from clicking the Delete button, I have the following:
If e.CommandName = "DeleteCustomer" Then
vCustomerID = e.CommandArgument 'should return the customer ID
DeleteCustomer(vCustomerID)
End If
...the problem is e.CommandArgument is returning the customer ID from the same row index from the first page. So again, what could cause this?
Thanks!!!!!
I should add this too, here's my gridview:
<asp:GridView runat="server" ID="UserCustomerGrd" DataKeyNames="CustomerID"
AllowPaging="true" PageSize="10" AutoGenerateColumns="false"
CellSpacing="0" CellPadding="3"
<Columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate><asp:LinkButton ID="DelBtn" OnClientClick="javascript:return confirm('Are you sure you wish to delete?')" CommandArgument='<%#Eval("CustomerID")%>' CommandName="Delete" runat="server">Delete</asp:LinkButton></ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CustomerID" HeaderText="Customer ID"/>
<asp:BoundField DataField="Name" HeaderText="Customer Name"/>
</Columns>
<PagerSettings Mode="NumericFirstLast" LastPageText="Last" FirstPageText="First" />
<PagerStyle HorizontalAlign="Center" />
</asp:GridView>