BinaryImageColumn

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

    Posted 13 Oct 2010 Link to this post

    Hello

    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">
    </asp:Content>
      
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" 
                AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
                DataSourceID="SqlDataSource1" GridLines="None" Skin="Windows7" 
                AllowCustomPaging="True" AllowFilteringByColumn="True" AllowSorting="True" 
                AutoGenerateHierarchy="True">
                <ExportSettings ExportOnlyData="True" FileName="Export">
                    <Excel Format="ExcelML" />
                </ExportSettings>
    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" 
                    DataKeyNames="ManufacturerName" DataSourceID="SqlDataSource1" Frame="Void" 
                    GridLines="None">
        <CommandItemSettings ShowExportToCsvButton="True" 
            ShowExportToExcelButton="True" 
            ShowExportToWordButton="True" />
        <Columns>
      
            <telerik:GridBoundColumn DataField="ManufacturerName" 
                HeaderText="Manufacturer Name" SortExpression="ManufacturerName" 
                UniqueName="ManufacturerName">
            </telerik:GridBoundColumn>
              
            <telerik:GridBinaryImageColumn AllowFiltering="False" AllowSorting="False" 
                DataField="ManufacturerLogo" DefaultInsertValue="" HeaderText="Logo" 
                ImageAlign="Middle" ImageHeight="100px" ImageWidth="100px" ResizeMode="Fit" 
                UniqueName="column" ConvertEmptyStringToNull="False">
            </telerik:GridBinaryImageColumn>
              
            <telerik:GridEditCommandColumn>
            </telerik:GridEditCommandColumn>
             
        </Columns>
      
    <EditFormSettings>
    <EditColumn UniqueName="EditCommandColumn1"></EditColumn>
    </EditFormSettings>
      
        <CommandItemStyle Height="50px" Width="50px" />
    </MasterTableView>
      
         </telerik:RadGrid>
           
           
            <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)" 
                  
             
                <UpdateParameters>
                    <asp:Parameter Name="ManufacturerName" />
                    <asp:Parameter Name="ManufacturerLogo" DbType="Binary" />
                </UpdateParameters>
                 
            </asp:SqlDataSource>
          
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            </telerik:RadScriptManager>
  2. Mira
    Admin
    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,
    Mira
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top