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

Capturing FileName/No.Of .Files uploaded through RadUpload.

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ranganath
Top achievements
Rank 1
Ranganath asked on 26 Jul 2008, 09:31 AM

HI,

Last few days I am posting the same prob again and again, but I am nt getting proper response .

Again now I am posting the prob once…

1:- I want to retrieve the uploaded file name and no of files from the RadUpload Control, which is under RadGrid.

My code looks like as follow…

<telerik:RadAjaxManager ID="RadAjaxManager2" DefaultLoadingPanelID="RadAjaxLoadingPanel1"

        runat="server">

        <AjaxSettings>

            <telerik:AjaxSetting AjaxControlID="RadGrid1" >

                <UpdatedControls>

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

                </UpdatedControls>

            </telerik:AjaxSetting>

        </AjaxSettings>

    </telerik:RadAjaxManager>

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

 

<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>

    </telerik:RadScriptBlock>

     <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" clientevents-onrequeststart="conditionalPostback"

        Width="75px" Transparency="5">

        <img style="margin-top: 150px;" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading4.gif") %>' />

    </telerik:RadAjaxLoadingPanel>

 

<telerik:RadGrid PageSize="3" AllowPaging="true" ID="RadGrid1" runat="server" GridLines="Horizontal"

        AllowFilteringByColumn="true" Skin="WebBlue" AllowAutomaticDeletes="True" OnNeedDataSource="RadGrid1_NeedDataSource"

        OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand"

        OnUpdateCommand="RadGrid1_UpdateCommand" OnItemDataBound="RadGrid1_ItemDataBound"

        OnItemInserted="RadGrid1_ItemInserted">

        <PagerStyle Mode="Slider" />

        <MasterTableView AutoGenerateColumns="false" DataKeyNames="TerritoryID" EditMode="EditForms"

            CommandItemDisplay="TopAndBottom">

            <Columns>

                <telerik:GridEditCommandColumn>

                </telerik:GridEditCommandColumn>

                <telerik:GridBoundColumn ReadOnly="true" HeaderText="TerritoryID" DataField="TerritoryID"

                    UniqueName="TerritoryID" />

                <telerik:GridBoundColumn ReadOnly="false" HeaderText="TerritoryDescription" DataField="TerritoryDescription"

                    UniqueName="TerritoryDescription" />

                <telerik:GridBoundColumn ReadOnly="false" HeaderText="RegionID" DataField="RegionID"

                    UniqueName="RegionID" />

                <telerik:GridButtonColumn CommandName="Delete" Text="Delete">

                </telerik:GridButtonColumn>

            </Columns>

            <EditFormSettings EditFormType="Template">

                <EditColumn UniqueName="EditCommandColumn1">

                </EditColumn>

                <FormTemplate>

                    <table id="Table2" cellspacing="2" cellpadding="1" width="250" border="1" rules="none"

                        style="border-collapse: collapse">

                        <tr>

                            <td>

                                <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0">

                                   

                                    <tr>

                                        <td>

                                            TerritoryID:

                                        </td>

                                        <td>

                                            <asp:TextBox ID="txtTerritoryID" MaxLength="5" Visible='<% # (Container as GridItem).OwnerTableView.IsItemInserted %>'

                                                runat="server">

                                            </asp:TextBox>

                                        </td>

                                    </tr>

                                    <tr>

                                        <td>

                                            TerritoryDescription:

                                        </td>

                                        <td>

                                            <asp:TextBox ID="txtTerritoryDescription" runat="server" Text='<%# Eval( "TerritoryDescription" ) %>'>

                                            </asp:TextBox>

                                        </td>

                                    </tr>

                                    <tr>

<td>

RegionID:                                                                                    </td>

<td>


<telerik:RadUpload ID="RadUpload1" runat="server" InitialFileInputsCount="1" MaxFileInputsCount="1"                                            ControlObjectsVisibility="None" AllowedFileExtensions=".aspx" />

</td>

</tr>

</table>

</td>

 </tr>

 <tr>

<td colspan="2">

<b>Territory Info:</b>

</td>

</tr>

<tr>

<td align="right" colspan="2">

 <asp:Button ID="btnUpdate" Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Insert" : "Update" %>'

                                    runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>

                                </asp:Button>&nbsp;

                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"

                                    CommandName="Cancel"></asp:Button>

                            </td>

                        </tr>

                    </table>

                </FormTemplate>

            </EditFormSettings>

        </MasterTableView>

    </telerik:RadGrid>

 

 

C#:-

protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)

{

        GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;

        RadAjaxManager2.Alert((item.FindControl("RadUpload1") as RadUpload).UploadedFiles.Count.ToString());

)

OR

protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)

    {

        GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;

        int cnt=(item.FindControl("RadUpload1") as RadUpload).UploadedFiles.Count;

        Response.Write((item.FindControl("RadUpload1") as RadUpload).UploadedFiles[0].FileName);

 

    }

 

Above either of the following ways I am  nt able to retreive any fiels, which I have uploaded through RadUpload control…

 

Please provide me solution int his regards…

Regards,
Ranganath.S

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 Jul 2008, 05:25 AM
Hello Ranganath,

I don't think that RadAjaxLoadingPanel have OnRequestStart client-side event:

clientevents-onrequeststart="conditionalPostback"

This should be assigned to the manager similar to our exampe!

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ranganath
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or