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

Cache to delete data for log file

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 1
Mario asked on 14 Apr 2012, 07:47 PM
Hello,
I need the data from the row which i will delete. I need this data for a log file. How can i do that?
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
    AutoGenerateColumns="False" CellSpacing="0" Culture="de-DE"
    DataSourceID="ObjectDataSource1" GridLines="None" Width="450px"
    AllowSorting="True" ShowFooter="True"
    ondeletecommand="RadGrid1_DeleteCommand"
    oninsertcommand="RadGrid1_InsertCommand" onitemcommand="RadGrid1_ItemCommand"
    onitemdatabound="RadGrid1_ItemDataBound"
    onupdatecommand="RadGrid1_UpdateCommand">
    <ClientSettings>
        <Selecting CellSelectionMode="None" />
    </ClientSettings>
    <MasterTableView AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
        AllowAutomaticUpdates="True" CommandItemDisplay="TopAndBottom"
        DataKeyNames="ResID" DataSourceID="ObjectDataSource1">
        <CommandItemSettings ExportToPdfText="Export to PDF" />
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
            Visible="True">
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
            Visible="True">
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridTemplateColumn DataField="ResWidth" DataType="System.Int32"
                FilterControlAltText="Filter ResWidth column"
                HeaderText="<%$ Resources:BasicSettings, Width %>" SortExpression="ResWidth"
                UniqueName="ResWidth">
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server"
                        Culture="de-DE" DbValue='<%# Bind("ResWidth") %>' LabelWidth="" MinValue="0"
                        Width="125px">
                        <NumberFormat DecimalDigits="0" ZeroPattern="n" />
                    </telerik:RadNumericTextBox>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ControlToValidate="RadNumericTextBox1" Display="Dynamic"
                        ErrorMessage="<%$ Resources:BasicSettings, RequiredValidation %>"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="ResWidthLabel" runat="server" Text='<%# Eval("ResWidth") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn DataField="ResHeight" DataType="System.Int32"
                FilterControlAltText="Filter ResHeight column"
                HeaderText="<%$ Resources:BasicSettings, Height %>" SortExpression="ResHeight"
                UniqueName="ResHeight">
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox2" Runat="server"
                        Culture="de-DE" DbValue='<%# Bind("ResHeight") %>' LabelWidth="" MinValue="0"
                        Width="125px">
                        <NumberFormat DecimalDigits="0" ZeroPattern="n" />
                    </telerik:RadNumericTextBox>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                        ControlToValidate="RadNumericTextBox2" Display="Dynamic"
                        ErrorMessage="<%$ Resources:BasicSettings, RequiredValidation %>"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="ResHeightLabel" runat="server" Text='<%# Eval("ResHeight") %>'></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton"
                FilterControlAltText="Filter EditCommandColumn column"
                HeaderText="<%$ Resources:BasicSettings, Edit %>">
            </telerik:GridEditCommandColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"
                ConfirmText="<%$ Resources:BasicSettings, ConfirmDelete %>"
                HeaderText="<%$ Resources:BasicSettings, Delete %>" Text="Delete"
                UniqueName="DeleteColumn">
            </telerik:GridButtonColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                UniqueName="EditCommandColumn1">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>                           
 
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    TypeName="ResolutionsBLL"
    InsertMethod="InsertResolutions"
    SelectMethod="GetResolutions" 
    DeleteMethod="DeleteResolution"
    UpdateMethod="UpdateResolution" >
    <DeleteParameters>
        <asp:Parameter Name="resID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="ResWidth" Type="Int32" />
        <asp:Parameter Name="ResHeight" Type="Int32" />
    </InsertParameters>
    <SelectParameters>
        <asp:Parameter DefaultValue="1" Name="resArt" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="resArt" Type="Int32" />
        <asp:Parameter Name="resWidth" Type="Int32" />
        <asp:Parameter Name="resHeight" Type="Int32" />
        <asp:Parameter Name="resID" Type="Int32" />
    </UpdateParameters>
</asp:ObjectDataSource>

I need the Id, ResWidth and ResHeight Data for the log file.
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
    try
    {
        int ID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ResID"].ToString());
 
        string logtext = string.Format("Delete {0} x {1}",
            oldWidth, oldHeight); // I need this here
 
        UserEventsBLL uev = new UserEventsBLL();
        uev.AddUserEvent(thisUser.UserName, "deleteRes", logtext, Request.Url.AbsolutePath, null, ID, null);
    }
    catch (Exception ex)
    {
        ErrorsBLL errors = new ErrorsBLL();
        errors.AddErrors(203, Request.Url.AbsolutePath, ex.Message, thisUser.UserName, "");
    }
}

I need the data in the line "string logtext = string.Formate ...".

Best regards

Reiner






1 Answer, 1 is accepted

Sort by
0
Mario
Top achievements
Rank 1
answered on 15 Apr 2012, 01:08 PM
I have it solved:
if (e.CommandName == "Delete")//RadGrid.DeleteCommandName)
{
    oldWidth = Convert.ToInt32((e.Item.FindControl("ResWidthLabel") as Label).Text);
    oldHeight = Convert.ToInt32((e.Item.FindControl("ResHeightLabel") as Label).Text);
}

Is that ok?

Best regards
Reiner



Tags
Grid
Asked by
Mario
Top achievements
Rank 1
Answers by
Mario
Top achievements
Rank 1
Share this question
or