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

Delete Issue

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alharith
Top achievements
Rank 1
Alharith asked on 11 Feb 2015, 11:22 AM
ASPX Code
<telerik:RadGrid ID="rgReceiptDTL" runat="server"
    AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True" AutoGenerateColumns="False"
    AllowMultiRowEdit="true" MasterTableView-EditMode="EditForms"
    Height="300px" MasterTableView-Dir="<%$ Resources:SystemResource, HTMLDirectionality %>"
    Width="98%" GroupPanelPosition="Top" DataSourceID="SDSReceiptDTL">
 
    <MasterTableView CommandItemDisplay="None"
        DataKeyNames="IDNo"
        GridLines="None" HorizontalAlign="NotSet" NoMasterRecordsText="<%$ Resources:Grid , NoMasterRecordsText %>" TableLayout="Fixed" Width="100%" DataSourceID="SDSReceiptDTL">
        <CommandItemSettings ExportToPdfText="Export to Pdf" />
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
        </ExpandCollapseColumn>
 
        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" Wrap="True" />
        <Columns>
            <telerik:GridTemplateColumn EditFormHeaderTextFormat="" DataField="ItemNo" meta:resourcekey="ItemNo"
                UniqueName="ItemNo">
                <HeaderStyle Width="85" />
                <ItemTemplate>
                    <telerik:RadTextBox SkinID="Medium"
                        Text='<%#Eval("ItemName")%>'
                        runat="server" ID="rtbItemName">
                    </telerik:RadTextBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn meta:resourcekey="ItemName">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
 
            <telerik:GridTemplateColumn meta:resourcekey="UnitPrice" DataField="UnitPrice">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn meta:resourcekey="PurchDate"
                DataField="PurchDate">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn meta:resourcekey="DepreciateRatio" DataField="DepreciateRatio">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn meta:resourcekey="originalFactorNo" DataField="originalFactorNo">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn DataField="Qty" meta:resourcekey="Qty"
                UniqueName="Qty">
                <HeaderStyle Width="130" />
            </telerik:GridTemplateColumn>
            <%--                          <telerik:GridTemplateColumn DataField="Total" meta:resourcekey="Total"
                UniqueName="Total">
            </telerik:GridTemplateColumn>--%>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"
                ConfirmDialogType="RadWindow" ConfirmText="<%$ Resources:Grid ,ConfirmDelete %>" ConfirmTitle="<%$ Resources:Grid ,Delete %>" FilterImageUrl="~\Design\TelerikSkins\Grid\Filter.gif" ImageUrl="~\Design\TelerikSkins\Grid\Delete.gif" SortAscImageUrl="~\Design\TelerikSkins\Grid\SortAsc.gif" SortDescImageUrl="~\Design\TelerikSkins\Grid\SortDesc.gif" Text="<%$ Resources:Grid ,Delete %>" UniqueName="column1">
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridButtonColumn>
        </Columns>
        <EditFormSettings EditFormType="Template">
            <FormTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td style="width: 85px">
                            <asp:Label runat="server" ID="lblItemNo" Text='<%#Eval("ItemNo")%>'></asp:Label>
                        </td>
                        <td style="width: 130px">
                            <telerik:RadTextBox SkinID="Medium"
                                Text='<%#Eval("ItemName")%>' AutoPostBack="true"
                                 OnTextChanged="rtbItemName_TextChanged"
                                runat="server" ID="rtbItemName">
                            </telerik:RadTextBox></td>
                        <td style="width: 130px">
                            <asp:Label runat="server" ID="lblUnitPrice" Text='<%#Eval("UnitPrice")%>'></asp:Label></td>
                        <td style="width: 130px">
                            <telerik:RadDatePicker SkinID="Medium"
                                DbSelectedDate='<%#Eval("PurchDate")%>'
                                runat="server" ID="rdpPurchDate">
                            </telerik:RadDatePicker>
                        </td>
                        <td style="width: 130px">
                            <telerik:RadNumericTextBox runat="server"
                                DbValue='<%#Eval("DepreciateRatio")%>'
                                ID="rntbDepreciateRatio"
                                SkinID="NumberMedium">
                            </telerik:RadNumericTextBox></td>
                        <td style="width: 130px">
                            <telerik:RadTextBox SkinID="Medium" runat="server" ID="rtboriginalFactorNo"></telerik:RadTextBox></td>
                        <td style="width: 130px">
                            <telerik:RadNumericTextBox runat="server" ID="rntbQTY" DbValue='<%#Eval("Qty")%>'
                                MaxValue='<%#Eval("Qty")%>'
                                SkinID="NumberMedium">
                            </telerik:RadNumericTextBox>
                        </td>
                        <td style="width: 50px;">
                            <asp:ImageButton runat="server" ID="btnDelete" ToolTip="Delete"
                                   CommandName="Delete"
                                ImageUrl="~\Design\TelerikSkins\Grid\Delete.gif" />
                        </td>
 
                    </tr>
                </table>
            </FormTemplate>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings>
        <Scrolling AllowScroll="True" SaveScrollPosition="False" ScrollHeight="200px" UseStaticHeaders="True" />
    </ClientSettings>
 
</telerik:RadGrid>
 
<cc1:SessionDataSource ID="SDSReceiptDTL"
    runat="server" ClearSessionOnInitialLoad="True"
    ConflictDetection="CompareAllValues"
    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
    SelectCommand="EXEC [Inv_ReceiptDtlSP] 'rtvLPODTL',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,@LPONO,@LPOYear"
    UpdateCommand="EXEC [Inv_ReceiptDtlSP] 'Save'"
    DeleteCommand="EXEC [Inv_ReceiptDtlSP] 'Delete'"
    InsertCommand="EXEC [Inv_ReceiptDtlSP] 'Save'"
    PrimaryKeyFields="IDNo"
    SessionKey="System.Web.UI.Page_SDSReceiptDTL">
    <SelectParameters>
        <asp:ControlParameter ControlID="hdnLPONO" Name="LPONO" PropertyName="Value" />
        <asp:ControlParameter ControlID="hdnLPOYear" Name="LPOYear" PropertyName="Value" />
    </SelectParameters>
</cc1:SessionDataSource>
<asp:HiddenField runat="server" ID="hdnLPONO" />
<asp:HiddenField runat="server" ID="hdnLPOYear" />

VB Code
Private Sub rgReceiptDTL_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles rgReceiptDTL.ItemCommand
 
    If e.CommandName = RadGrid.DeleteCommandName Then
 
    End If
End Sub
Private Sub rgReceiptDTL_ItemDataBound(sender As Object, e As GridItemEventArgs) Handles rgReceiptDTL.ItemDataBound
    rgReceiptDTL.EditIndexes.Add(e.Item.ItemIndex)
    e.Item.Edit = True
End Sub
 
Protected Sub rgReceiptDTL_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgReceiptDTL.PreRender
    If (rgReceiptDTL.EditItems.Count > 0) Then
        For Each item As GridDataItem In rgReceiptDTL.MasterTableView.Items
            item.Visible = False
        Next
    End If
End Sub

in this code im working on edited item only the data item always not visible 

i face a probem when delete item from Grid every thing user added will be deleted because of rebind

how can i update all items in session data source when delete an item ?

THXX 

1 Answer, 1 is accepted

Sort by
0
Alharith
Top achievements
Rank 1
answered on 11 Feb 2015, 01:26 PM
I Figured that im using Eval not Bind ill change it and try Again
Tags
Grid
Asked by
Alharith
Top achievements
Rank 1
Answers by
Alharith
Top achievements
Rank 1
Share this question
or