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
165
Insert UltraWebGrid + WebHierarchicalDataSource + sqldatasource
posted

database configuration:

Activity: (parent)

ActivityID (Primary Key)

EstimateItem:  (child)

EstimateItemID (Primary Key)

ActivityID (Foreign Key)

What is required in the UltraWebGrid or SqlDataSource settings to insert a child record and pull the parent Primary key to populate the child table Foreign Key?  Do I need to set a control parameter = ???

 

Parents
No Data
Reply
  • 4555
    Suggested Answer
    posted

    Hi,

    You can use the Grid's UpdateRow event. Call an insert statement for the parent and assign the value that comes back from the server to the child. If the identity field is the first column in both the Parent and Child, then your code would look similar to:

     

     

     

     

     

     

    protected

    void UltraWebGrid1_UpdateRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)

     {

           

    if (e.Row.DataChanged.ToString() == "Modified")

             {

             }

     

     

            else if (e.Row.DataChanged.ToString() == "Added")

           {

     

     

           if (e.Row.Band.Index == 0)

           {

     

     

           int order = new Class1().insertRow(e.Row);

           e.Row.Cells[0].Value = order;

          }

     

     

    if (e.Row.Band.Index == 1)

        {

         e.Row.Cells[0].Value = e.Row.ParentRow.Cells[0].Value;

        Class1 myclass =

    new Class1();

     }

     

     

     

Children
No Data