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
60
Post Updates to WebHierarchicalDataSource using WebGrid
posted

I have created a WebHierarchicalDataSource with 2 underlying SqlDataSource controls with a simple parent-child relationship that I am attempting to bind to a grid. The grid displays all data correctly with all parent and child rows, however when a row is updated the change is not posted back to the SQL server.

To troubleshoot, I created a second grid on the same page and bound it directly to the parent SqlDataSource and updates work fine on that grid - settings on both grids are exactly the same other than the data source that they point to.

  •  AJAX is enabled on both grids
  • BaseTableName and DataKeyField are configured on both grids
  • BaseColumnName and IsBound are configured on all columns on both grids
  • UpdateRow event handler is present for both grids

Am I missing something?!? Thanks in advance for helping a noob...

Parents
  • 28464
    posted

    Hello, 

    The setup seems perfectly valid, the only thing that might be missing is to auto-generate the Update/Insert/Delete/Read command oof the underlying datasources - they are not generated by default. You can switch to design mode, click "Configure" for both datasource and then there are a couple of tabs on the righr (I think they were called "Advanced") and there you can generate the commands.

    Was this the problem? Other than that, I just tried this setup of the grid (with Access, but same principles should apply) and it worked just fine

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ultrawebgrid_crud.aspx.cs" Inherits="_Default" %>

    <%@ Register Assembly="Infragistics35.Web.v8.2, Version=8.2.20082.1, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
        Namespace="Infragistics.Web.UI.DataSourceControls" TagPrefix="aikido" %>
    <%@ Register Assembly="Infragistics35.WebUI.UltraWebGrid.v8.2, Version=8.2.20082.1, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
        Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="igtbl" %>
       
       
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
       
        <asp:ScriptManager runat="server" ID="ScriptManager1" />
       
        <igtbl:UltraWebGrid
            ID="UltraWebGrid1"
            runat="server"
            Width="725px"
            DataSourceID="WebHierarchicalDataSource1"
            oninitializerow="UltraWebGrid1_InitializeRow">
            <Bands>
                <igtbl:UltraGridBand BaseTableName="Categories" DataKeyField="CategoryID">
                    <AddNewRow Visible="NotSet" View="NotSet">
                    </AddNewRow>
                </igtbl:UltraGridBand>
                <igtbl:UltraGridBand BaseTableName="Products" DataKeyField="ProductID">
                    <AddNewRow Visible="NotSet" View="NotSet">
                    </AddNewRow>               
                </igtbl:UltraGridBand>
               
            </Bands>
            <DisplayLayout Name="UltraWebGrid1" BorderCollapseDefault="Separate" RowHeightDefault="20px" ViewType="Hierarchical"
                Version="4.00" AllowUpdateDefault="Yes">
                <FrameStyle BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="8pt"
                    Height="200px" Width="325px">
                </FrameStyle>
                <Pager>
                    <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
                        <BorderDetails ColorLeft="White" ColorTop="White" />
                    </PagerStyle>
                </Pager>
                <EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
                </EditCellStyleDefault>
                <HeaderStyleDefault BackColor="LightGray" BorderStyle="Solid">
                    <BorderDetails ColorLeft="White" ColorTop="White" />
                </HeaderStyleDefault>
                <RowStyleDefault BackColor="White" BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px"
                    Font-Names="Verdana" Font-Size="8pt">
                    <Padding Left="3px" />
                    <BorderDetails ColorLeft="White" ColorTop="White" />
                </RowStyleDefault>
                <AddNewBox>
                    <BoxStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
                        <BorderDetails ColorLeft="White" ColorTop="White" />
                    </BoxStyle>
                </AddNewBox>
                <ActivationObject BorderColor="" BorderWidth="">
                </ActivationObject>
            </DisplayLayout>
        </igtbl:UltraWebGrid>
       
        <aikido:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">
            <DataRelations>
                <aikido:DataRelation ChildColumns="CategoryID"
                    ChildDataViewID="AccessDataSource2_DefaultView" ParentColumns="CategoryID"
                    ParentDataViewID="AccessDataSource1_DefaultView" />
            </DataRelations>
            <DataViews>
                <aikido:DataView ID="AccessDataSource1_DefaultView" DataMember="DefaultView"
                    DataSourceID="AccessDataSource1" />
                <aikido:DataView ID="AccessDataSource2_DefaultView" DataMember="DefaultView"
                    DataSourceID="AccessDataSource2" />
            </DataViews>
        </aikido:WebHierarchicalDataSource>

        <asp:AccessDataSource ID="AccessDataSource1" runat="server"
            DataFile="~/App_Data/Northwind.mdb"
            SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
        </asp:AccessDataSource>
        <asp:AccessDataSource ID="AccessDataSource2" runat="server"
            DataFile="~/App_Data/Northwind.mdb"
            SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Products]">
        </asp:AccessDataSource>


       
        </form>
    </body>
    </html>
     

Reply Children
No Data