This is a migrated thread and some comments may be shown as answers.

Update/Insert/Delete in Hierarchy

3 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
El
Top achievements
Rank 1
El asked on 28 Dec 2010, 05:08 PM

I have an extra RadGrid as Detail Table which needs to be editable (update, insert, delete). 

I thought that DetailTable contains the needed Event Handlers for that but obviously i was wrong. 

So now, i don't know how do i do that. I am using RadGrid1_DetailTableDataBind event to bind the nested Grid to Datatable:

Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
 
 If e.DetailTableView.Name = "Payments" Then
     Dim PurchaseID As Integer = Convert.ToInt16(dataItem.GetDataKeyValue("SaleID").ToString)
     e.DetailTableView.DataSource = PurchasesAccess.GetPayments(PurchaseID)
 End If

However i still don't know how do i call UpdateCommand, InsertCommand and DeleteCommand for the grid which is detail table. 

I am not using SqlDataSource objects and such. Rather i am using classes and stored procedures. 

Thanks

3 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 28 Dec 2010, 05:57 PM
I have a 3-level grid which does insert/update/delete on all but the highest level
<telerik:RadGrid ID="rgSpiffDetail" DataSourceID="sdsVendors" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" AllowFilteringByColumn="true"
AllowAutomaticInserts="False" AllowAutomaticDeletes="False" AllowAutomaticUpdates="False" Width="95%" runat="server" >
<GroupingSettings CaseSensitive="false" />       
<MasterTableView Name="Vendors" DataSourceID="sdsVendors" DataKeyNames="VendorID" CommandItemDisplay="None" Width="100%">
    <DetailTables>
        <telerik:GridTableView Name="Spiffs" DataKeyNames="SpiffID" DataSourceID="sdsSpiffs" CommandItemDisplay="Top" AllowFilteringByColumn="False" Width="100%" runat="server" >
        <CommandItemSettings AddNewRecordText="New Spiff" />
        <ParentTableRelation>
            <telerik:GridRelationFields MasterKeyField="VendorID" DetailKeyField="VendorID" />
        </ParentTableRelation>
        <DetailTables>
            <telerik:GridTableView Name="Items" DataKeyNames="SpiffID,ItemID" DataSourceID="sdsItems" CommandItemDisplay="Top" AllowFilteringByColumn="False" Width="100%" runat="server" >
            <CommandItemSettings AddNewRecordText="Chose Item(s)" />
            <ParentTableRelation>
                <telerik:GridRelationFields MasterKeyField="SpiffID" DetailKeyField="SpiffID" />
            </ParentTableRelation>
        <Columns>
            <telerik:GridBoundColumn UniqueName="VendorID" DataField="VendorID" Visible="False" />
            <telerik:GridBoundColumn UniqueName="SpiffID" DataField="SpiffID" HeaderText="SpiffID" />
            <telerik:GridBoundColumn UniqueName="ItemID" DataField="ItemID" HeaderText="ItemID" />
            <telerik:GridBoundColumn UniqueName="KMSPartNo" DataField="KMSPartNo" HeaderText="KMS Part Number" />
            <telerik:GridBoundColumn UniqueName="LNSPartNo" DataField="LNSPartNo" HeaderText="LNS Part Number" />
            <telerik:GridBoundColumn UniqueName="Description" DataField="Description" HeaderText="Description" />
            <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" Text="Remove" />
        </Columns>
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
            <table border="0" cellpadding="2" cellspacing="2">
            <tr>
            <td>Items</td>
            <td>
                <telerik:RadListBox ID="rlbItems" SelectionMode="Multiple" AutoPostBack="true" Width="300px" runat="server" />
            </td>
            </tr>
            <tr>
            <td>
                <asp:Button ID="btnCancel" Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" />
            </td>
            <td>
                <asp:Button ID="btnAddtoSpiff" Text="Add to Spiff" CommandName="PerformInsert" runat="server" />
            </td>
            </tr>
            </table>
            </FormTemplate>
        </EditFormSettings>
        </telerik:GridTableView>                                               
        </DetailTables>
    <Columns>
        <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Edit" /> 
        <telerik:GridBoundColumn UniqueName="SpiffID" DataField="SpiffID" HeaderText="SpiffID" ReadOnly="True" />
        <telerik:GridBoundColumn UniqueName="Seq" DataField="Seq" HeaderText="seq" />               
        <telerik:GridTemplateColumn UniqueName="CashBack" HeaderText="CashBack" >
            <ItemTemplate>
                <asp:Label ID="lblCashBack" Text='<%# Bind("CashBack") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbCashBack" text='<%# Eval("CashBack") %>' runat="server">
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
                <asp:RequiredFieldValidator ID="rfvCashBack" ControlToValidate="rntbCashBack" ErrorMessage="Required" runat="server" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn UniqueName="CaseDollarItem" DataField="CaseDollarItem" HeaderText="CaseDollarItem" />
        <telerik:GridCheckBoxColumn UniqueName="AllorByItem" DataField="AllOrByItem" HeaderText="AllItems" />
        <telerik:GridTemplateColumn UniqueName="QtytoOrder" HeaderText="Qty to Order">
            <ItemTemplate>
                <asp:Label ID="lblQtytoOrder" Text='<%# Bind("QtytoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbQtytoOrder" Text='<%# Eval("QtytoOrder") %>' runat="server" >
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="DollartoOrder" HeaderText="$ to Order">
            <ItemTemplate>
                <asp:Label ID="lblDollartoOrder" Text='<%# Eval("DollartoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbDollartoOrder" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinQty" HeaderText="Min Qty">
            <ItemTemplate>
                <asp:Label ID="lblMinQty" Text='<%# Eval("MinQty") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinQty" runat="server" >
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinDollar" HeaderText="Min Dollar">
            <ItemTemplate>
                <asp:Label ID="lblMinDollar" Text='<%# Eval("MinDollar") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinDollar" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="SpiffDescription" >
            <ItemTemplate>
                <asp:Label ID="lblSpiffDescription" Text='<%# Eval("SpiffDescription") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadTextBox ID="rtbSpiffDescription" Text='<%# Eval("SpiffDescription") %>' Width="500px" runat="server">
                </telerik:RadTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" Text="Delete" />
    </Columns>
    </telerik:GridTableView>
</DetailTables>
<Columns>
    <telerik:GridBoundColumn UniqueName="VendorID" DataField="VendorID" Allowfiltering="False" HeaderText="VendorID" />
    <telerik:GridBoundColumn UniqueName="KMSPrefix" DataField="KMSPrefix"  CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="True" HeaderText="KMS Prefix" />
    <telerik:GridBoundColumn UniqueName="VendorName" DataField="VendorName" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="True" HeaderText="VendorName">
        <HeaderStyle Width="200" />
    </telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
code behind
Imports Telerik.Web.UI
Imports System.Data
 
Partial Class SpiffMaintenance
    Inherits System.Web.UI.Page
 
    'Dim Quicksilver_VendorID As Integer = 309
    Dim VendorID As Integer
 
    Protected Sub rgSpiffDetail_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgSpiffDetail.NeedDataSource
        Dim VendorID As Integer = 0
        Dim ds As DataSet = Nothing
        Dim dt As DataTable = Nothing
 
        If rcbVendors.SelectedValue = String.Empty Then
            VendorID = Quicksilver_VendorID
        Else
            VendorID = rcbVendors.SelectedValue
        End If
        Dim ws As New CommonFunctions
        If e Is Nothing Then
        ElseIf e.IsFromDetailTable Then
            Exit Sub
        End If
        ds = ws.GetSpiffs(VendorID)
        If ds.Tables.Count > 0 Then
            dt = ds.Tables(0)
        End If
        rgSpiffDetail.DataSource = dt
    End Sub
 
    Protected Sub rgSpiffDetail_DetailTableDataBind(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles rgSpiffDetail.DetailTableDataBind
        Dim gdItem As GridDataItem = Nothing
        Dim SpiffID As Integer = 0
        Dim ds As DataSet = Nothing
        Dim dt As DataTable = Nothing
 
        gdItem = CType(e.DetailTableView.ParentItem, GridDataItem)
        SpiffID = CInt(gdItem.GetDataKeyValue("SpiffID"))
        Dim ws As New CommonFunctions
        ds = ws.GetItemsforSpiff(SpiffID)
    End Sub
 
     Protected Sub rcbVendors_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles rcbVendors.SelectedIndexChanged
        Dim ea As Telerik.Web.UI.GridNeedDataSourceEventArgs = Nothing
        rgSpiffDetail.Rebind()
    End Sub
 
    Protected Sub rgSpiffDetail_ItemDataBound(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgSpiffDetail.ItemDataBound
 
    End Sub
 
    Protected Sub rgSpiffDetail_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgSpiffDetail.ItemCommand
        Dim TableName, CommandName As String
        Dim gcItem As GridCommandItem = Nothing
        Dim gefiItem As GridEditFormInsertItem = Nothing
        Dim geItem As GridEditableItem = Nothing
        Dim gdItem As GridDataItem = Nothing
        Dim gefItem As GridEditFormItem = Nothing
        Dim gdSpiff, gdVendor As GridDataItem
        Dim SpiffID, ItemID As Integer
        Dim rlbItems As RadListBox = Nothing
        Dim ws As CommonFunctions = Nothing
 
        CommandName = e.CommandName
        Select Case CommandName
            Case "InitInsert"
                gcItem = DirectCast(e.Item, GridCommandItem)
                TableName = gcItem.OwnerTableView.Name
                If TableName = "Items" Then
                    gdSpiff = e.Item.OwnerTableView.ParentItem
                    gdVendor = gdSpiff.OwnerTableView.ParentItem
                    VendorID = gdVendor.OwnerTableView.DataKeyValues(gdVendor.ItemIndex)("VendorID")
                End If
            Case "PerformInsert"
                If TypeOf e.Item Is GridEditFormInsertItem Then
                    gefiItem = DirectCast(e.Item, GridEditFormInsertItem)
                    TableName = gefiItem.OwnerTableView.Name
                    If TableName = "Spiffs" Then
                        InsertSpiff(gefiItem)
                    ElseIf TableName = "Items" Then
                        gdSpiff = e.Item.OwnerTableView.ParentItem
                        SpiffID = gdSpiff.OwnerTableView.DataKeyValues(gdSpiff.ItemIndex)("SpiffID")
                        geItem = DirectCast(e.Item, GridEditableItem)
                        rlbItems = CType(geItem.Cells(1).FindControl("rlbItems"), RadListBox)
                        If rlbItems.SelectedItems.Count > 1 Then
                            ApplyMultipleSelections(SpiffID, rlbItems)
                        Else
                            ItemID = rlbItems.SelectedValue
                            ws = New CommonFunctions
                            ws.ApplyItemtoSpiff(SpiffID, ItemID)
                        End If
                    End If
                End If
            Case "Delete"
                gdItem = DirectCast(e.Item, GridDataItem)
                TableName = gdItem.OwnerTableView.Name
                If TableName = "Items" Then
                    ItemID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("ItemID"))
                    SpiffID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("SpiffID"))
                    ws = New CommonFunctions
                    ws.DecoupleItemFromSpiff(ItemID, SpiffID)
                ElseIf TableName = "Spiffs" Then
                    SpiffID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("SpiffID"))
                    ws = New CommonFunctions
                    ws.DeleteSpiffDetail(SpiffID)
                End If
            Case "Update"
                If TypeOf e.Item Is GridEditFormItem Then
                    gefItem = DirectCast(e.Item, GridEditFormItem)
                    TableName = gefItem.OwnerTableView.Name
                    If TableName = "Spiffs" Then
                        UpdateSpiff(gefItem)
                    End If
                End If
        End Select
    End Sub
 
    Private Sub ApplyMultipleSelections(ByVal SpiffID As Integer, ByVal rlbItems As RadListBox)
        Dim rlbItem As RadListBoxItem = Nothing
        Dim ws As New CommonFunctions
        Dim i, ItemID As Integer
 
        ws = New CommonFunctions
        For i = 0 To rlbItems.SelectedItems.Count - 1
            rlbItem = rlbItems.SelectedItems(i)
            ItemID = rlbItem.Value
            ws.ApplyItemtoSpiff(SpiffID, ItemID)
        Next
 
    End Sub
 
    Private Sub InsertSpiff(ByVal gefiItem As GridEditFormInsertItem)
        Dim txtSeq, txtCaseDollarItem As TextBox
        Dim rntbCashBack, rntbQtytoOrder, rntbDollartoOrder, _
            rntbMinQty, rntbMinDollar As RadNumericTextBox
        Dim chkAllorByItem As CheckBox = Nothing
        Dim tcSpiffDescription As TableCell = Nothing
        Dim rtbSpiffDescription As RadTextBox = Nothing
        Dim Seq, QtytoOrder, MinQty, VendorID, SpiffID As Integer
        Dim CashBack, DollartoOrder, MinDollar As Double
        Dim CaseDollarItem, AllorByItem As Char
        Dim SpiffDescription As String = String.Empty
        Dim gdVendor As GridDataItem
        Dim ws As CommonFunctions = Nothing
 
        gdVendor = gefiItem.OwnerTableView.ParentItem
        VendorID = gdVendor.OwnerTableView.DataKeyValues(gdVendor.ItemIndex)("VendorID")
        txtSeq = DirectCast(gefiItem("Seq").Controls(0), TextBox)
        rntbCashBack = DirectCast(gefiItem("CashBack").Controls(1), RadNumericTextBox)
        txtCaseDollarItem = DirectCast(gefiItem("CaseDollarItem").Controls(0), TextBox)
        chkAllorByItem = DirectCast(gefiItem("AllorByItem").Controls(0), CheckBox)
        rntbQtytoOrder = DirectCast(gefiItem("QtytoOrder").Controls(1), RadNumericTextBox)
        rntbDollartoOrder = DirectCast(gefiItem("DollartoOrder").Controls(1), RadNumericTextBox)
        rntbMinQty = DirectCast(gefiItem("MinQty").Controls(1), RadNumericTextBox)
        rntbMinDollar = DirectCast(gefiItem("MinDollar").Controls(1), RadNumericTextBox)
        tcSpiffDescription = gefiItem.Cells(1)
        rtbSpiffDescription = DirectCast(tcSpiffDescription.FindControl("rtbSpiffDescription"), RadTextBox)
        If txtCaseDollarItem.Text = "I" _
        Or txtCaseDollarItem.Text = "C" _
        Or txtCaseDollarItem.Text = "D" Then
        Else
            Exit Sub
        End If
        If txtSeq.Text.Trim = String.Empty Then
            Seq = 0
        Else
            Seq = CInt(txtSeq.Text)
        End If
        CashBack = rntbCashBack.Value
        CaseDollarItem = CType(txtCaseDollarItem.Text, Char)
        AllorByItem = IIf(chkAllorByItem.Checked, "A", "I")
        QtytoOrder = CInt(NullableValue(rntbQtytoOrder))
        DollartoOrder = NullableValue(rntbDollartoOrder)
        MinQty = CInt(NullableValue(rntbMinQty))
        MinDollar = NullableValue(rntbMinDollar)
        SpiffDescription = rtbSpiffDescription.Text
        ws = New CommonFunctions
        SpiffID = ws.InsertSpiffDetail(VendorID, Seq, SpiffDescription, _
            CashBack, AllorByItem, CaseDollarItem, QtytoOrder, DollartoOrder, _
            MinQty, MinDollar)
    End Sub
 
    Private Function NullableValue(ByVal rntBox As RadNumericTextBox) As Object
        Dim dValue As Double = 0
        If rntBox.Value Is Nothing Then
        Else
            dValue = rntBox.Value
        End If
        Return dValue
    End Function
 
    Private Sub UpdateSpiff(ByVal gefItem As GridEditFormItem)
        Dim txtSeq, txtCaseDollarItem As TextBox
        Dim rntbCashBack, rntbQtytoOrder, rntbDollartoOrder, _
            rntbMinQty, rntbMinDollar As RadNumericTextBox
        Dim tcSpiffDescription As TableCell = Nothing
        Dim rtbSpiffDescription As RadTextBox = Nothing
        Dim chkAllorByItem As CheckBox = Nothing
        Dim Seq, QtytoOrder, MinQty, SpiffID As Integer
        Dim CashBack, DollartoOrder, MinDollar As Double
        Dim CaseDollarItem, AllorByItem As Char
        Dim SpiffDescription As String = String.Empty
        Dim ws As CommonFunctions = Nothing
 
        txtSeq = DirectCast(gefItem("Seq").Controls(0), TextBox)
        rntbCashBack = DirectCast(gefItem("CashBack").Controls(1), RadNumericTextBox)
        txtCaseDollarItem = DirectCast(gefItem("CaseDollarItem").Controls(0), TextBox)
        chkAllorByItem = DirectCast(gefItem("AllorByItem").Controls(0), CheckBox)
        rntbQtytoOrder = DirectCast(gefItem("QtytoOrder").Controls(1), RadNumericTextBox)
        rntbDollartoOrder = DirectCast(gefItem("DollartoOrder").Controls(1), RadNumericTextBox)
        rntbMinQty = DirectCast(gefItem("MinQty").Controls(1), RadNumericTextBox)
        rntbMinDollar = DirectCast(gefItem("MinDollar").Controls(1), RadNumericTextBox)
        tcSpiffDescription = gefItem.Cells(1)
        rtbSpiffDescription = DirectCast(tcSpiffDescription.FindControl("rtbSpiffDescription"), RadTextBox)
 
        SpiffID = CInt(gefItem.OwnerTableView.DataKeyValues(gefItem.ItemIndex)("SpiffID"))
        If txtSeq.Text.Trim = String.Empty Then
            Seq = 0
        Else
            Seq = CInt(txtSeq.Text)
        End If
        CashBack = rntbCashBack.Value
        CaseDollarItem = CType(txtCaseDollarItem.Text, Char)
        AllorByItem = IIf(chkAllorByItem.Checked, "A", "I")
        QtytoOrder = CInt(NullableValue(rntbQtytoOrder))
        DollartoOrder = NullableValue(rntbDollartoOrder)
        MinQty = CInt(NullableValue(rntbMinQty))
        MinDollar = NullableValue(rntbMinDollar)
        SpiffDescription = rtbSpiffDescription.Text
        ws = New CommonFunctions
        ws.UpdateSpiffDetail(SpiffID, Seq, SpiffDescription, CashBack, _
        AllorByItem, CaseDollarItem, QtytoOrder, DollartoOrder, _
        MinQty, MinDollar)
    End Sub
 
    Protected Sub rgSpiffDetail_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgSpiffDetail.ItemCreated
        Dim tableName As String = String.Empty
        Dim gcItem As GridCommandItem = Nothing
        tableName = e.Item.OwnerTableView.Name
        If tableName = "Items" Then
            If TypeOf e.Item Is GridCommandItem Then
                gcItem = DirectCast(e.Item, GridCommandItem)
                If gcItem.Cells.Count > 0 Then
                    Dim obj As Object = gcItem.Cells(0)
                End If
            End If
        End If
    End Sub
 
    Protected Sub rgSpiffDetail_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgSpiffDetail.ItemDataBound
        Dim TableName As String = String.Empty
        Dim geItem As GridEditableItem = Nothing
        Dim rlbItems As RadListBox = Nothing
        Dim ds As DataSet = Nothing
        Dim ws As CommonFunctions = Nothing
 
        TableName = e.Item.OwnerTableView.Name
        If TableName = "Items" Then
        Else
            Exit Sub
        End If
 
        If TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode Then
            geItem = DirectCast(e.Item, GridEditableItem)
            rlbItems = CType(geItem.Cells(1).FindControl("rlbItems"), RadListBox)
            ws = New CommonFunctions
            ds = ws.GetAvailableItemsForVendor(VendorID)
            If ds Is Nothing Then
            ElseIf ds.Tables.Count > 0 Then
                rlbItems.DataSource = ds
                rlbItems.DataValueField = "ItemID"
                rlbItems.DataTextField = "DropDownText"
                rlbItems.DataBind()
            End If
        End If
    End Sub
 
    Protected Sub cmdPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
        Response.Redirect("AllReports.aspx")
    End Sub
End Class

the Print button just prints out the table(s) maintained
0
El
Top achievements
Rank 1
answered on 29 Dec 2010, 10:25 AM

Ok but i do update the both (parent radgrid and gridtableview)

<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Windows7"
                AllowAutomaticDeletes="true"
                AllowAutomaticUpdates="true" 
                AllowAutomaticInserts="true"
                AllowPaging="true" 
                PageSize="10" GridLines="None" 
                AutoGenerateColumns="false"
                AutoGenerateDeleteColumn="false">
      
            <MasterTableView DataKeyNames="SaleID" CommandItemDisplay="Top" PagerStyle-Position="Bottom" PagerStyle-Mode="NextPrevAndNumeric">
            <CommandItemSettings AddNewRecordText="Add new purchase" />
            <NoRecordsTemplate>
                <asp:Label ID="NoRecordsLabel" runat="server" Text="There isn't upgrade purchase(s) for this customer yet!" />
            </NoRecordsTemplate>
            <DetailTables>                
                <telerik:GridTableView DataKeyNames="payment_ID" Name="Payments" Width="100%">
                  
                    <NoRecordsTemplate>
                        There is no payment on this purchase.
                    </NoRecordsTemplate>
                    <Columns>
                        <telerik:GridBoundColumn UniqueName="PaymentIDCol" DataField="payment_ID" HeaderText="Payment ID" Display="true" />
                        <telerik:GridNumericColumn UniqueName="AmountCol" DataField="Amount" HeaderText="Amount" NumericType="Currency" />
                        <telerik:GridBoundColumn UniqueName="DatePaidCol" DataField="DatePaid" HeaderText="Date Paid" />
                        <telerik:GridTemplateColumn HeaderText="Payment Status" UniqueName="PaymentStatusCol">
                            <ItemTemplate>
                                <asp:Label ID="StatusLabel" runat="server" Text='<%# If(Eval("PaymentStatus") = "False", "Declined", "Successful") %>' />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
  
                        <telerik:GridEditCommandColumn HeaderText="" 
                        EditImageUrl="~/admin/images/gridedit.gif"
                        ButtonType="ImageButton" Display="true" />
          
                        <telerik:GridButtonColumn 
                        ButtonType="ImageButton"
                        CommandName="Delete" 
                        HeaderText="" 
                        ImageUrl="~/admin/images/griddelete.gif" 
                        ConfirmDialogType="RadWindow" 
                        ConfirmText="Are you sure you want to delete this payment?" Display="true" />
                    </Columns>
                    <EditFormSettings InsertCaption="Add new payment" CaptionFormatString="Edit Payment: {0}"
                                CaptionDataField="payment_ID" EditFormType="Template">
                        <FormTemplate>
                          <!-- a lots of fields to be edited here -->
                        </FormTemplate>
                    </EditFormSettings
  
                </telerik:GridTableView>
            </DetailTables>
              
            <Columns>
                <telerik:GridTemplateColumn HeaderText="Purchase ID" UniqueName="IDCol" Display="false">
                    <ItemTemplate>
                        <asp:Label ID="NoteID" runat="server" Text='<%# Eval("SaleID") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>  
                <telerik:GridDateTimeColumn UniqueName="SaleDateCol" DataField="SaleDate" HeaderText="Sale Date" />                                  
                <telerik:GridTemplateColumn HeaderText="Package Name" UniqueName="PackageNameCol">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("PackageName") %>' ID="PackageNameLabel" runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                       <telerik:RadTextBox runat="server" ID="PackageNameEdit" Skin="Windows7" />              
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
          
                <telerik:GridTemplateColumn HeaderText="Price" UniqueName="PriceCol">
                    <ItemTemplate>
                        <asp:Label Text='<%# String.Format("${0:n2}", Decimal.Parse(Eval("Price").ToString)) %>' ID="PriceLabel" runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadNumericTextBox ID="PriceEdit" runat="server" Value="0" Width="100px" MaxLength="100" MinValue="0" MaxValue="100000" Type="Currency" Skin="Windows7" NumberFormat-DecimalDigits="2" />
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
          
                <telerik:GridTemplateColumn HeaderText="Sale Date" UniqueName="SaleDateCol" Display="false">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("SaleDate") %>' runat="server" ID="SaleDateLabel" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
  
                <telerik:GridTemplateColumn HeaderText="Description" UniqueName="PackageDescriptionCol">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("PackageDescription") %>' ID="PackageDescriptionLabel" runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadTextBox ID="PackageDescriptionEdit" runat="server" TextMode="MultiLine" Width="200px" MaxLength="1024" Skin="Windows7" />
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
  
                <telerik:GridTemplateColumn HeaderText="Sale Rep" UniqueName="SaleRepIDCol" Display="false">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("SaleRepID") %>' ID="SaleRepIDLabel" runat="server" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="SaleRepIDEdit" runat="server" MaxHeight="200px" Skin="Windows7" />
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
  
                <telerik:GridEditCommandColumn HeaderText="" 
                EditImageUrl="~/admin/images/gridedit.gif"
                ButtonType="ImageButton" />
          
                <telerik:GridButtonColumn 
                ButtonType="ImageButton"
                CommandName="Delete" 
                HeaderText="" 
                ImageUrl="~/admin/images/griddelete.gif" 
                ConfirmDialogType="RadWindow" 
                ConfirmText="Are you sure you want to delete this purchase?" />
            </Columns>
              
            </MasterTableView>
            </telerik:RadGrid>

I believe i should check if it's radgrid or gridtableview in all RadGrid's events and response adequately. e.g. In the ItemDataBound i should also Bind the gridtableview's controls but if the typeof object is gridtableview etc. 

I am assuming which is probably not right but, the above example actually does not suit my scenario. 

Thank you so much

0
Elliott
Top achievements
Rank 2
answered on 29 Dec 2010, 08:01 PM
all you have to do is check e.Item.OwnerTableView.Name to know which level generated the event
Tags
Grid
Asked by
El
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
El
Top achievements
Rank 1
Share this question
or