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

Radupload in Radgrikd has UploadedFiles.Count = 0

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Teerayut
Top achievements
Rank 1
Teerayut asked on 07 Mar 2009, 07:17 PM
Someone please, help me.

I've create radupload in radgrid like this demo : http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=upload
i've many columns than demo.It's sound like not have a problem.
But I've. I don't know why.

this is my code
ASPX

<

 

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

 

 

<AjaxSettings>

 

 

<telerik:AjaxSetting AjaxControlID="rdgNews">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="rdgNews" LoadingPanelID="RadAjaxLoadingPanel1" />

 

 

</UpdatedControls>

 

 

</telerik:AjaxSetting>

 

 

 

</AjaxSettings>

 

 

</telerik:RadAjaxManager>

 

 

<telerik:RadGrid ID="rdgNews" runat="server" AllowAutomaticDeletes="True"

 

 

AllowAutomaticInserts="True" AllowAutomaticUpdates="True"

 

 

AutoGenerateColumns="False" DataSourceID="odsNews" GridLines="None"

 

 

Skin="Sunset" onitemdatabound="rdgNews_ItemDataBound"

 

 

oninsertcommand="rdgNews_InsertCommand"

 

 

onupdatecommand="rdgNews_UpdateCommand">

 

 

<HeaderContextMenu EnableTheming="True">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</HeaderContextMenu>

 

 

<MasterTableView AllowPaging="True" DataKeyNames="NewsID" DataSourceID="odsNews"

 

 

CommandItemDisplay="Top" PageSize="30">

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

 

<telerik:GridEditCommandColumn ButtonType="ImageButton">

 

 

</telerik:GridEditCommandColumn>

 

 

<telerik:GridBoundColumn DataField="NewsID" DataType="System.Int64"

 

 

HeaderText="NewsID" ReadOnly="True" SortExpression="NewsID" UniqueName="NewsID"

 

 

Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="NewsCode" HeaderText="รหัส"

 

 

SortExpression="NewsCode" UniqueName="NewsCode">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="NewsHeadLine" HeaderText="เรื่อง"

 

 

SortExpression="NewsHeadLine" UniqueName="NewsHeadLine">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn DataField="NewsDetail" HeaderText="รายละเอียด"

 

 

SortExpression="NewsDetail" UniqueName="NewsDetail" Visible="False">

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="NewsDetailTextBox" runat="server" Columns="50" Rows="5"

 

 

Text='<%# Bind("NewsDetail") %>' TextMode="MultiLine"></asp:TextBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="NewsDetailLabel" runat="server" Text='<%# Eval("NewsDetail") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="NewsReporter" HeaderText="ผู้รายงาน"

 

 

SortExpression="NewsReporter" UniqueName="NewsReporter" ReadOnly="true" >

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn DataField="NewsResource" HeaderText="รายละเอียด"

 

 

SortExpression="NewsResource" UniqueName="NewsResource" Visible="False">

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="NewsResourceTextBox" runat="server" Columns="50" Rows="5"

 

 

Text='<%# Bind("NewsResource") %>' TextMode="MultiLine"></asp:TextBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="NewsResourceLabel" runat="server" Text='<%# Eval("NewsResource") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn DataField="NewsConcern" HeaderText="ข้อพิจารณา"

 

 

SortExpression="NewsConcern" UniqueName="NewsConcern" Visible="False">

 

 

<EditItemTemplate>

 

 

<asp:TextBox ID="NewsConcernTextBox" runat="server" Columns="50" Rows="5"

 

 

Text='<%# Bind("NewsConcern") %>' TextMode="MultiLine"></asp:TextBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="NewsConcernLabel" runat="server" Text='<%# Eval("NewsConcern") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="NewsUpdateDate" DataType="System.DateTime"

 

 

HeaderText="วันที่ปรับปรุงข้อมูล" SortExpression="NewsUpdateDate" Visible="false"

 

 

UniqueName="NewsUpdateDate">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="NewsUpdateUserName"

 

 

HeaderText="ชื่อผู้ใช้" SortExpression="NewsUpdateUserName" ReadOnly="true"

 

 

UniqueName="NewsUpdateUserName">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridDropDownColumn DataField="NewsOwnerDepartment" HeaderText="หน่วยงาน"

 

 

EnableEmptyListItem = "true" SortExpression="NewsOwnerDepartment" UniqueName="NewsOwnerDepartment"

 

 

EmptyListItemText="--กรุณาเลือกหน่วยงาน--" EmptyListItemValue=""

 

 

ListTextField="DepartmentCodeName" ListValueField="DepartmentID" DataSourceID="odsDepartments" >

 

 

</telerik:GridDropDownColumn>

 

 

<telerik:GridDropDownColumn DataField="NewsReportArea" DataType="System.Byte"

 

 

EmptyListItemText="--กรุณาเลือกจังหวัด--" EmptyListItemValue="" EnableEmptyListItem = "true"

 

 

HeaderText="พื้นที่" SortExpression="NewsReportArea" DataSourceID="odsProvince"

 

 

UniqueName="NewsReportArea" ListValueField="ProvinceID" ListTextField="ProvinceName">

 

 

</telerik:GridDropDownColumn>

 

 


<
telerik:GridTemplateColumn DataField="NewsFileName" HeaderText="เอกสารแนบ"

 

 

UniqueName="NewsFileName">

 

 

<EditItemTemplate>

 

 

<telerik:RadUpload ID="rulDocument" runat="server" Skin="Sunset"

 

 

InitialFileInputsCount="1" MaxFileInputsCount="1"

 

 

ControlObjectsVisibility="None" MaxFileSize="1000000" />

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:HyperLink ID="hplDocument" runat="server"

 

 

ImageUrl='<%# DisplayDocumentIcon(Eval("NewsSecretLevel")) %>'

 

 

NavigateUrl='<%# "~/Files/" + Eval("NewsFileName").ToString()+Eval("NewsFileExtension").ToString() %>'>

 

 

</asp:HyperLink>

 

 



</
ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="NewsFileExtension" Visible="false"

 

 

HeaderText="NewsFileExtension" SortExpression="NewsFileExtension"

 

 

UniqueName="NewsFileExtension">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn DataField="NewsDateTimeReport"

 

 

DataType="System.DateTime" HeaderText="วันที่"

 

 

SortExpression="NewsDateTimeReport" UniqueName="NewsDateTimeReport">

 

 

<EditItemTemplate>

 

 

<telerik:RadDateTimePicker ID="NewsDateTimeReportRadDatePicker" runat="server"

 

 

DbSelectedDate='<%# Bind("NewsDateTimeReport") %>'>

 

 

</telerik:RadDateTimePicker>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

<asp:Label ID="NewsDateTimeReportLabel" runat="server"

 

 

Text='<%# Eval("NewsDateTimeReport","{0:D}")%>'></asp:Label>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="NewsStatus" DataType="System.Byte"

 

 

HeaderText="สถานะ" SortExpression="NewsStatus" UniqueName="NewsStatus">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridDropDownColumn DataField="NewsSecretLevel" DataType="System.Byte"

 

 

HeaderText="ชั้นความลับ" SortExpression="NewsSecretLevel" DataSourceID="odsSecretLevel"

 

 

UniqueName="NewsSecretLevel" ListValueField="SecretLevelID" ListTextField="SecretLevelName">

 

 

</telerik:GridDropDownColumn>

 

 

 

<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"

 

 

Text="ลบ" UniqueName="DeleteColumn">

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn1"></EditColumn>

 

 

</EditFormSettings>

 

 

<PagerStyle Mode="Slider" />

 

 

</MasterTableView>

 

 

<FilterMenu EnableTheming="True">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</FilterMenu>

 

 

</telerik:RadGrid>

 

 

 

<asp:ObjectDataSource ID="odsNews" runat="server" DeleteMethod="DeleteNews" SelectMethod="GetNews"

 

 

TypeName="News" InsertMethod="AddNews" UpdateMethod="UpdateNews"

 

 

OldValuesParameterFormatString="{0}">

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="newsID" Type="Int32" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="newsCode" Type="String" />

 

 

<asp:Parameter Name="newsHeadline" Type="String" />

 

 

<asp:Parameter Name="newsDetail" Type="String" />

 

 

<asp:Parameter Name="newsDateTimeReport" Type="DateTime" />

 

 

<asp:Parameter Name="newsReporter" Type="String" />

 

 

<asp:Parameter Name="newsResource" Type="String" />

 

 

<asp:Parameter Name="newsConcern" Type="String" />

 

 

<asp:Parameter Name="newsSecretLevel" Type="Byte" />

 

 

<asp:Parameter Name="newsUpdateDate" Type="DateTime" />

 

 

<asp:Parameter Name="newsUpdateUserName" Type="String" />

 

 

<asp:Parameter Name="newsOwnerDepartment" Type="Byte" />

 

 

<asp:Parameter Name="newsFileName" Type="String" />

 

 

<asp:Parameter Name="newsFileExtension" Type="String" />

 

 

<asp:Parameter Name="newsStatus" Type="Byte" />

 

 

<asp:Parameter Name="newsReportArea" Type="Byte" />

 

 

<asp:Parameter Name="newsID" Type="Int64" />

 

 

</UpdateParameters>

 

 

<InsertParameters>

 

 

<asp:Parameter Name="newsCode" Type="String" />

 

 

<asp:Parameter Name="newsHeadline" Type="String" />

 

 

<asp:Parameter Name="newsDetail" Type="String" />

 

 

<asp:Parameter Name="newsDateTimeReport" Type="DateTime" />

 

 

<asp:Parameter Name="newsReporter" Type="String" />

 

 

<asp:Parameter Name="newsResource" Type="String" />

 

 

<asp:Parameter Name="newsConcern" Type="String" />

 

 

<asp:Parameter Name="newsSecretLevel" Type="Byte" />

 

 

<asp:Parameter Name="newsUpdateDate" Type="DateTime" />

 

 

<asp:Parameter Name="newsUpdateUserName" Type="String" />

 

 

<asp:Parameter Name="newsOwnerDepartment" Type="Byte" />

 

 

<asp:Parameter Name="newsFileName" Type="String" />

 

 

<asp:Parameter Name="newsFileExtension" Type="String" />

 

 

<asp:Parameter Name="newsStatus" Type="Byte" />

 

 

<asp:Parameter Name="newsReportArea" Type="Byte" />

 

 

</InsertParameters>

 

 

</asp:ObjectDataSource>

 

 

 

<asp:ObjectDataSource ID="odsDepartments" runat="server"

 

 

SelectMethod="GetDepartmentsByID" TypeName="Departments"

 

 

DeleteMethod="DeleteDepartment"

 

 

OldValuesParameterFormatString="{0}"

 

 

UpdateMethod="UpdateDepartment">

 

 

<DeleteParameters>

 

 

<asp:Parameter Name="departmentID" Type="Int16" />

 

 

</DeleteParameters>

 

 

<UpdateParameters>

 

 

<asp:Parameter Name="departmentName" Type="String" />

 

 

<asp:Parameter Name="departmentDetail" Type="String" />

 

 

<asp:Parameter Name="departmentCodeName" Type="String" />

 

 

<asp:Parameter Name="departmentPhone" Type="String" />

 

 

<asp:Parameter Name="departmentFax" Type="String" />

 

 

<asp:Parameter Name="departmentAddress" Type="String" />

 

 

<asp:Parameter Name="departmentDistrict" Type="String" />

 

 

<asp:Parameter Name="departmentProvince" Type="String" />

 

 

<asp:Parameter Name="departmentID" Type="Int16" />

 

 

</UpdateParameters>

 

 

<SelectParameters>

 

 

<asp:SessionParameter Name="departmentID" SessionField="DepartmentID"

 

 

Type="Int16" />

 

 

</SelectParameters>

 

 

</asp:ObjectDataSource>

 

 

<asp:ObjectDataSource ID="odsProvince" runat="server" SelectMethod="GetProvincesByRegion"

 

 

TypeName="Provinces">

 

 

<SelectParameters>

 

 

<asp:SessionParameter DefaultValue="1" Name="regionID" SessionField="RegionID"

 

 

Type="Byte" />

 

 

</SelectParameters>

 

 

</asp:ObjectDataSource>

 

 

<asp:ObjectDataSource ID="odsSecretLevel" runat="server"

 

 

OldValuesParameterFormatString="{0}" SelectMethod="GetSecretLevels"

 

 

TypeName="SecretLevel"></asp:ObjectDataSource>

 

 

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"

 

 

Height="75px" Width="75px" Transparency="20" style="margin-top: 99px">

 

 

<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" />

 

 

</telerik:RadAjaxLoadingPanel>

 

-----------------------------------------------

aspx.cs

I've selected file in aspx page and in code behind
i've written code to find radupload control with e.item.findcontrol
but UploadedFiles.Count  = 0

-----------------------------------------------

 

 

protected void rdgNews_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

 

{

 

 

 

 

if (IsValid)

 

{

 

RadUpload uploader = (RadUpload)e.Item.FindControl("rulDocument");

 

 

long id = (long)rdgNews.MasterTableView.DataKeyValues[e.Item.ItemIndex]["NewsID"];

 

 

UploadedFile docFile = null;

 

 

string targetFolder = uploader.TargetFolder;

 

 

if (uploader.UploadedFiles.Count > 0)

 

{

docFile = uploader.UploadedFiles[0];

docFile.SaveAs(Server.MapPath(targetFolder) + id + docFile.GetExtension(),

true);

 

odsNews.UpdateParameters[

"NewsFileName"].DefaultValue = "" + docFile.GetExtension();

 

odsNews.UpdateParameters[

"NewsFileExtension"].DefaultValue = docFile.GetExtension();

 

}

 

}

I use 8 hour to solve this problem but i can't  someone please help me.
Thank you

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2009, 04:59 AM
Hello Teerayut,

You would have to disable Ajax for the grid while uploading since RadUpload cannot upload files using AJAX calls. Make sure that you have not missed out on the following code to disable Ajax on insert and update as shown in the demo:
<script type="text/javascript"
  //On insert and update buttons click temporarily disables ajax to perform upload actions 
  function conditionalPostback(e, sender) 
  { 
    var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig"); 
    if (sender.EventTarget.match(theRegexp)) 
    { 
      var upload = $find(window['UploadId']); 
      //AJAX is disabled only if file is selected for upload 
      if(upload.getFileInputs()[0].value != "") 
      { 
        sender.EnableAjax = false
      } 
    } 
  } 
 </script> 

Thanks
Princy.
Tags
Grid
Asked by
Teerayut
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or