This is a migrated thread and some comments may be shown as answers.
Error from FileUpload control using within RadGrid
0 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
John John
Top achievements
Rank 1
John John asked on 18 May 2011, 07:51 PM
We  are trying to upload a file from a RadEditPopup which is opened from a Radgrid control. However, we could not get the file name from the RadUpload control. The RadUpload control returns a null value for the file name (it works properly when the control sits on a stand-alone page as in your web-demo for this control).  For your reference, I have  pasted code below which demonstrates the problem we are experiencing. Your prompt attention to this issue would be greatly appreciated. Thank you for your time, and we look forward to hearing from Telerik Support very soon.

ASPX Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI, Version=2009.3.1103.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
    Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<head>
 
    <script language="javascript">  
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadGrid ID="RadFormsLibrary" runat="server" AutoGenerateColumns="false"
            Skin="Vista" EnableLinqExpressions="false" Width="100%"
            OnNeedDataSource="RadFormsLibrary_NeedDataSource"
            onupdatecommand="RadFormsLibrary_UpdateCommand">
            <MasterTableView TableLayout="Fixed" Name="Forms" GroupLoadMode="Client" EditMode="PopUp"
                AllowSorting="true" AllowMultiColumnSorting="True">
                <HeaderStyle CssClass="HeaderStyle" />
                <ItemStyle CssClass="ItemStyle" />
                <AlternatingItemStyle CssClass="AlternatingItemStyle" />
                <NoRecordsTemplate>
                    <div style="background-color: Silver; height: 20px; color: Red; text-align: center;
                        font-size: 10pt; font-family: Verdana; font-weight: bold;">
                        <i>No forms defined for this application.</i>
                    </div>
                </NoRecordsTemplate>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="Options" AllowFiltering="false" Reorderable="false"
                        Groupable="false" UniqueName="Options" HeaderStyle-Width="6%">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkEdit" CommandName="Edit" Text="Edit" runat="server"></asp:LinkButton>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="EID" DataField="EID" UniqueName="EID" HeaderStyle-Width="7%">
                        <ItemTemplate>
                            <asp:Label ID="lblJuris" ToolTip='<%# Eval("EID") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <PopUpSettings ScrollBars="Auto" Modal="true" />
                    <FormTemplate>
                        <telerik:RadUpload ID="RUPhoto" runat="server" ControlObjectsVisibility="None" AllowedFileExtensions=".jpg,.jpeg"
                            Skin="Office2007">
                        </telerik:RadUpload>
                         <asp:Button ID="btnUpdate" runat="server" Text="Submit" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>      
    </div>
    </form>
</body>
</html>


Code Behind Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
 
public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void Button1_Click(object sender, EventArgs e)
    {
        string fileName = RUPhoto.UploadedFiles[0].FileName;
        Response.Write(fileName);
    }
 
 
    public DataTable GetData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("EID");
 
        for(int i=0;i<=5;i++)
        {
            DataRow dr = dt.NewRow();
            dr[0]=i;
            dt.Rows.Add(dr);
        }
        return dt;
    }
    protected void RadFormsLibrary_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable dt=GetData();
        RadFormsLibrary.DataSource = dt;
    }
    protected void RadFormsLibrary_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        RadUpload rdFileName = e.Item.FindControl("dlFileName") as RadUpload;
        string fileName = rdFileName.UploadedFiles[0].FileName;
    }
}
    

No answers yet. Maybe you can help?

Asked by
John John
Top achievements
Rank 1
Share this question
or