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>

Parents
  • 1300
    Verified Answer
    Offline posted

    Hello Joey,

    I have created a sample using WebHierarchicalDataGrid with template column containing a button and Add New Row feature, however, on my side the correct command argument is passed to the method when new row is added.

    Below I am attaching the prepared sample. Could you please modify it in order to demonstrate the described behaviour and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach in in this case.

    Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.

    Additionally, what I could suggest is enabling the Activation feature and accessing the current row from the active cell in the WebHierarchicalDataGrid1_ItemCommand method. This could be achieved as follows:

    protected void WebHierarchicalDataGrid1_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)

        {

            GridRecord row = WebHierarchicalDataGrid1.GridView.Behaviors.Activation.ActiveCell.Row;

        }

    Thank you for your cooperation.

    Looking forward to hearing from you.

    Regards,
    Monika Kirkova,
    Infragistics

    WebHierarchicalDataGridDataSource.zip

Reply Children
No Data