2 posts, 0 answers
  1. Luciaen
    Luciaen avatar
    1 posts
    Member since:
    Oct 2010

    Posted 13 Oct 2010 Link to this post


    I have column defined like BinaryImageColumn in Radgridview

    when I press edit I can modify existing record with all textfields and I have pregenerated control where I can select image

    Issue if I do not select any image it will remove exiting image Why it responding like this normally it must not touch change data if it is

    exist ? Do somebody know solution many Thanks in advance

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" 
                AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
                DataSourceID="SqlDataSource1" GridLines="None" Skin="Windows7" 
                AllowCustomPaging="True" AllowFilteringByColumn="True" AllowSorting="True" 
                <ExportSettings ExportOnlyData="True" FileName="Export">
                    <Excel Format="ExcelML" />
    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" 
                    DataKeyNames="ManufacturerName" DataSourceID="SqlDataSource1" Frame="Void" 
        <CommandItemSettings ShowExportToCsvButton="True" 
            ShowExportToWordButton="True" />
            <telerik:GridBoundColumn DataField="ManufacturerName" 
                HeaderText="Manufacturer Name" SortExpression="ManufacturerName" 
            <telerik:GridBinaryImageColumn AllowFiltering="False" AllowSorting="False" 
                DataField="ManufacturerLogo" DefaultInsertValue="" HeaderText="Logo" 
                ImageAlign="Middle" ImageHeight="100px" ImageWidth="100px" ResizeMode="Fit" 
                UniqueName="column" ConvertEmptyStringToNull="False">
    <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
        <CommandItemStyle Height="50px" Width="50px" />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:dbConnectionString %>" 
                SelectCommand="SELECT * FROM [tbl_manufacturers]" 
                UpdateCommand="UPDATE tbl_manufacturers SET ManufacturerName = @ManufacturerName, ManufacturerLogo = @ManufacturerLogo WHERE (ManufacturerName = @ManufacturerName)" 
                    <asp:Parameter Name="ManufacturerName" />
                    <asp:Parameter Name="ManufacturerLogo" DbType="Binary" />
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
  2. Mira
    Mira avatar
    1124 posts

    Posted 18 Oct 2010 Link to this post

    Hello Luciaen,

    I have followed your scenario and prepared a sample project for you. You can find it attached to this message. It shows how to update the image field only when an image is uploaded. This is done by setting the update command according to whether a file is selected for upload:
    void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        if (e.CommandName == RadGrid.UpdateCommandName)
            GridEditableItem editedItem = e.Item as GridEditableItem;
            GridEditManager editMan = editedItem.EditManager;
            RadUpload upload = new RadUpload();
            foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
                if (column is IGridEditableColumn)
                    IGridEditableColumn editableCol = (column as IGridEditableColumn);
                    if (editableCol.IsEditable)
                        IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);
                        if (editor is GridBinaryImageColumnEditor)
                            upload = (editor as GridBinaryImageColumnEditor).RadUploadControl;
            if (upload.UploadedFiles.Count == 0)
                SqlDataSource1.UpdateCommand = "UPDATE [Images] SET [Name] = @Name, [Description] = @Description WHERE [ID] = @ID";

    I hope this helps.

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top