how to make filename a defaultvalue for an insert parameter

Thread is closed for posting
2 posts, 0 answers
  1. Hamza
    Hamza avatar
    24 posts
    Member since:
    Feb 2011

    Posted 16 Sep 2011 Link to this post

    hi all :)

    I have a grid with template column, Item mode is a binary Image, and edit mode is a rad upload

    how can I get the file name and make it an insert parameter default value ?

    here is my code


    <telerik:GridTemplateColumn DataField="Data" HeaderText="Image" UniqueName="Upload">
            <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" ImageUrl='<%# Eval("User_AvatarPath") %>'
                AutoAdjustImageControlSize="false" Height="80px" Width="80px"
            <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" OnClientFileUploaded="OnClientFileUploaded"
                AllowedFileExtensions="jpg,jpeg,png,gif" MaxFileSize="1048576"
                 OverwriteExistingFiles="false" >

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Telerik.Charting;
    using Telerik.Web.UI;
    using System.Data.SqlClient;
    public partial class HTKfjksh7869435fds435_ljagut32542GSDFG_lgjdfsh32452GR235GGOJA324_Contros_NewItem_WebUserControl : System.Web.UI.UserControl
        protected void Page_Load(object sender, EventArgs e)
            SqlDataSource1.UpdateParameters["User_AvatarPath"].DefaultValue = _ImagePath;
            SqlDataSource1.InsertParameters["User_AvatarPath"].DefaultValue = _ImagePath;
        const int MaxTotalBytes = 1048576; // 1 MB
        int totalBytes;
        private static string _ImageName = "";
        private static string _ImagePath = "~/Pic's/Users/" + _ImageName;
        public bool? IsRadAsyncValid
                if (Session["IsRadAsyncValid"] == null)
                    Session["IsRadAsyncValid"] = true;
                return Convert.ToBoolean(Session["IsRadAsyncValid"].ToString());
                Session["IsRadAsyncValid"] = value;
        public void RadAsyncUpload1_ValidatingFile(object sender, Telerik.Web.UI.Upload.ValidateFileEventArgs e)
            if ((totalBytes < MaxTotalBytes) && (e.UploadedFile.ContentLength < MaxTotalBytes))
                e.IsValid = true;
                totalBytes += e.UploadedFile.ContentLength;
                IsRadAsyncValid = true;
                _ImageName = e.UploadedFile.GetName();
                e.IsValid = false;
                IsRadAsyncValid = false;

    thank you all :)
  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 20 Sep 2011 Link to this post

    Hello Hamza,

    Please review the following demos - RadAsyncUpload into Grid and RadUpload into Grid.

    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top