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
15
WebHierarchicalDataGrid CommandArgument References Different Row
posted

Hi all.  This is my first post to this forum so hopefully it won't be too cringe.

I have a WebHierarchicalDataGrid that is bound to WebHierarchicalDataSource.  The parent table has a SQL autonumber ID. 

In the parent row, I've added a template column with a "Save" button.  The button has a CommandName and CommandArgument (code below) that references the row's ID column.  All of this works great.  The command is called on the server when the button is clicked and the server creates an Excel file with the data from the given record ID that's downloaded to the client.

So, the issue I just discovered is that if a new record is added (via another user on a different computer) while this page is displayed, the CommandArgument doesn't reference the ID in the same row as the button.  Instead, it references the ID of the row above it.  However, when I refresh the page, the ID is correct.  Any thoughts on this?  I've told the end user that they should just refresh the page before clicking the button but they would like to fix this in case the user just forgets to refresh and the file that's downloaded is not the one they requested.

Thanks!

P.S. I also tried using the Row Index instead but that had the same result.

Here's the WHDG header.

<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="600px" Width="100%" AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ID"
DataMember="transDataSource_DefaultView" DataSourceID="WebHierarchicalDataSource1" Key="transDataSource_DefaultView" OnItemCommand="WebHierarchicalDataGrid1_ItemCommand">

Here's the template column with the button.

<ig:TemplateDataField Key="Save">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Save" CommandName="SaveTransaction" CommandArgument='<%# Eval("ID") %>' />
</ItemTemplate>
</ig:TemplateDataField>