Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
118 views
Hello,

I want to use the files selected from the Upload control to populate a grid.

below is my code, please provide examples I had trouble following the documentation...It wasn't exactly what I wanted, I want the same interface of selecting documents that the upload control provides, but I want to make a collection of those documents and then set it as the datasource for my grid.

Here is my code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default3.aspx.cs" Inherits="MultiFileUploadPrototype.Default3" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2011.3.1305.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  
<head id="Head1" runat="server">
  
    <style type="text/css">
        .binaryImage img
        {
            border: 1px solid;
        }
    </style>
  
</head>
  
<body class="BODY">
  
    <form runat="server" id="mainForm" method="post">
  
        <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
  
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
          
            <script type="text/javascript">
                  
                //On insert and update buttons click temporarily disables ajax to perform upload actions
                function conditionalPostback(sender, eventArgs) {
                    var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                    if (eventArgs.get_eventTarget().match(theRegexp)) {
                        var upload = $find(window['UploadId']);
  
                        //AJAX is disabled only if file is selected for upload
                        if (upload.getFileInputs()[0].value != "") {
                            eventArgs.set_enableAjax(false);
                        }
                    }
                }
  
                function validateRadUpload(source, e) {
                    e.IsValid = false;
  
                    var upload = $find(source.parentNode.getElementsByTagName('div')[0].id);
                    var inputs = upload.getFileInputs();
                    for (var i = 0; i < inputs.length; i++) {
                        //check for empty string or invalid extension
                        if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
                            e.IsValid = true;
                            break;
                        }
                    }
                }
  
                var $ = $telerik.$;
  
                function onClientFileUploaded(radAsyncUpload, args) {
                    //                    var $row = $(args.get_row());
                    //                    var categoryInputName = radAsyncUpload.getAdditionalFieldID("TextBox");
                    //                    var categoryInputType = "text";
                    //                    var categoryInputID = categoryInputName;
                    //                    var categoryInput = createInput(categoryInputType, categoryInputID, categoryInputName);
                    //                    var categoryLabel = createLabel(categoryInputID, "Category");
  
                    //                    var subCategoryInputName = radAsyncUpload.getAdditionalFieldID("ComboBox");
                    //                    var subCategoryInputID = subCategoryInputName;
                    //                    var subCategoryInput = createComboBox(subCategoryInputID);
                    //                    var subCategoryLabel = createLabel(subCategoryInputID, "Category");
  
                    //                    $row.append("<br/>");
                    //                    $row.append(categoryLabel);
                    //                    $row.append(categoryInput);
                    //                    $row.append("<br/>");
                    //                    $row.append(subCategoryLabel);
                    //                    $row.append(subCategoryInput);
                }
  
            </script>
  
        </telerik:RadCodeBlock>
          
        <div class="FileDetails">
            <telerik:RadAsyncUpload runat="server" 
                                    id="RadAsyncUpload1"
                                    OnClientFileUploaded="onClientFileUploaded" 
                                    MultipleFileSelection="Automatic" 
                                    OnFileUploaded="RadAsyncUpload1_OnFileUploaded">
            </telerik:RadAsyncUpload>
        </div>
  
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
  
            <telerik:RadProgressManager ID="RadProgressManager1" runat="server" />
            <telerik:RadProgressArea ID="RadProgressArea1" runat="server" />
  
            <telerik:RadGrid runat="server" 
                             ID="RadGrid1" 
                             AllowPaging="True" 
                             AllowSorting="True"
                             AutoGenerateColumns="False" 
                             Width="97%" 
                             ShowStatusBar="True"
                             GridLines="None"
                             PageSize="4" 
                             OnItemDataBound="RadGrid1_ItemDataBound" 
                             OnItemCreated="RadGrid1_ItemCreated" >
                  
                <PagerStyle Mode="NumericPages" AlwaysVisible="true" />
  
                <MasterTableView CommandItemDisplay="Top" 
                                 EditMode="InPlace" 
                                 AutoGenerateColumns="false" 
                                 AllowMultiColumnSorting="True" 
                                 EnableNoRecordsTemplate="False" 
                                 DataKeyNames="DocID" 
                                 IsFilterItemExpanded="False">
                      
                    <CommandItemTemplate>
                           <table width="100%">
                                <tr>
                                       <td width="40px">
                                            <asp:linkbutton id="btnRefresh" runat="server" commandname="RebindGrid">
                                            <img id="imgRebindGrid" style="border: 0px; vertical-align: middle;" alt="Refresh Data"
                                                runat="server" src="~/images/grids/refresh_small.gif" /></asp:linkbutton>
                                       </td>
                                       <td>
                                                <asp:linkbutton id="btnClearSort" runat="server" commandname="ClearSort">
                                                <img id="img1" style="border: 0px; vertical-align: middle;" alt="Clear Sorting"
                                                    runat="server" src="~/images/grids/Filter_Delete.gif" /></asp:linkbutton>
                                       </td>
                                       <td align="right">
                                                Show  
                                                <asp:dropdownlist ID="ddlFilterByDays" runat="server" Width="70px" commandname="filterbydays" AutoPostBack="true" >
                                                        <asp:ListItem Value="7">7 days</asp:ListItem>
                                                        <asp:ListItem Value="14">14 days</asp:ListItem>
                                                        <asp:ListItem Value="30">30 days</asp:ListItem>
                                                        <asp:ListItem Value="60">60 days</asp:ListItem>
                                                        <asp:ListItem Value="-1">ALL</asp:ListItem>
                                                </asp:dropdownlist>         
                                        </td>
                                </tr>
                           </table>
                    </CommandItemTemplate>
  
                    <Columns>
                          
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" ToolTip="Edit Record" runat="server" CausesValidation="False" CommandName="EditItem" ImageUrl="~/Images/Grids/edit_pencil_small.gif" />
                            </ItemTemplate>  
                        </telerik:GridTemplateColumn>
  
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:ImageButton ID="btnDelete" ToolTip="Delete Record" runat="server" CausesValidation="False"
                                                 CommandName="DeleteItem" OnClientClick="return GetUserConfirmForItemDelete(event);"
                                                 ImageUrl="~/Images/Delete.gif" />
                                                          
                            </ItemTemplate>             
                        </telerik:GridTemplateColumn>
  
                        <telerik:GridBoundColumn DataField="FileName" AllowFiltering="true" HeaderText="File Name" SortExpression="FileName" UniqueName="FileName" />
                      
                        <telerik:GridBoundColumn DataField="Category" AllowFiltering="true" HeaderText="Category" HeaderStyle-Wrap="true" SortExpression="Category" UniqueName="Category" />
                          
                        <telerik:GridBoundColumn DataField="SubCategory" AllowFiltering="true" HeaderText="Sub Category" HeaderStyle-Wrap="true" SortExpression="SubCategory" UniqueName="SubCategory" />
                          
                    </Columns>
  
                </MasterTableView>
  
                <ClientSettings>
                    <Selecting AllowRowSelect="false" /> 
                </ClientSettings>
  
            </telerik:RadGrid>
  
        </telerik:RadAjaxPanel>
       
    </form>
</body>
</html>

I have a class called uploadedDocument, which contains an ID, Name, Category and Subcategory.  How do I on the server side create a collection of this type based on the documents selected (for example, the document name I would use for the Name property and empty string for the other properties).

Thanks,

Thanks!
Plamen
Telerik team
 answered on 24 Jan 2012
3 answers
101 views
Currently we are evaluating upload controls provided by Telerik. Is HttpModules(s) mandatory for RadAsyncUpload(using Silverlight client) & RadUpload controls if we want to have progress bar.
Plamen
Telerik team
 answered on 24 Jan 2012
2 answers
98 views
Hi!

I'm implementing the DBFileBrowserContentProvider class to access to a Sql Server data base. It works fine if I use a web site but if I use a web application when I try to show the file the handler doesn't work. Does anybody have an idea about what I'm doing wrong?

The example I'm following is the next

http://www.telerik.com/community/code-library/aspnet-ajax/file-explorer/connect-radfileexplorer-or-radeditor-to-a-sql-databse.aspx

This example uses a web site but when I try to do the same in a web application, the hanlder file is never invoked and the file is never shown

Thanks in advance
Israel
Top achievements
Rank 1
 answered on 24 Jan 2012
3 answers
266 views
hello friends,

i am using the RadEditor in my application.

in my .aspx page i have some controls in the middle of those controls RadEditor is present, so i set the focus to the first controls on my aspx page, when ever i open my .aspx page focus is coming the first control after that i am pressing the Tab key  it is going to the next control, once it reaches to the RadEditor control(i.e., in the content area) if i press the Tab within that content area only focus is moving that is also fine. Now, my problem is i had some controls after RadEditor, so how can i move the focus to those controls using Tab key .

Thanks.
Richard
Top achievements
Rank 1
 answered on 24 Jan 2012
1 answer
131 views
Hi,

I was able get the FileExplorer to show files in a relative path within my project.
I'm now trying to show files in a physical location in my machine 'C:/Mediacontent/1' but I keep getting this error :

'C:/MediaContent/1' is a physical path, but a virtual path was expected.

I based my code in this example and I'm using a plain FileSystemContentProvider as the content provider type.
Can you help please?





Dobromir
Telerik team
 answered on 24 Jan 2012
1 answer
89 views
Hi,

I have a problem with the RTL resources (GUI related problems).
By trying to upload an image using the ImageManager (for example), The Upload window opens (View attached screen-shot), but not orgnized well (Not all labels are aligned to right and there is scrollers).

I'm uisng the following resources in order to change the language:
RadEditor.Dialogs.resx
RadEditor.Main.resx
RadEditor.Modules.resx
RadEditor.Tools.resx
RadListBox.resx
RadProgressArea.resx
RadScheduler.Main.resx
RadSpell.Dialog.resx
RadUpload.resx

By the way, the version which is used in this application is 2009.3.1314.35.

Please, I need your help in order to solve the above problem.

Regards,
Bader

Rumen
Telerik team
 answered on 24 Jan 2012
1 answer
93 views
Is it possible to configure a Dock/DockZone such that I can resize a dock both horizontally and vertically?

I'm starting to doubt my sanity; it seems logical that I should be able to do this, I just can't figure out how.

--
Stuart
Richard
Top achievements
Rank 1
 answered on 24 Jan 2012
2 answers
170 views
hi 
i have a RadGrid, popup Edit template which has two buttons the insert/update and cancel button, clicking cancel button causes Rad Confirm to be displayed but there is another default cancel button at the right corner of the popup is there any way make this button views the same Rad Confirm or hide it, any help ?

thank you 
Rasheed
Top achievements
Rank 1
 answered on 24 Jan 2012
1 answer
770 views
I started with a simple grid on a page as follows:
<telerik:RadGrid ID="rgSelectCourses" runat="server" AllowSorting="True"
     Width="860px" Height="500px" PageSize="20" CellSpacing="0"
     DataSourceID="sdsCourses" AllowMultiRowSelection="True"
     GridLines="None" AutoGenerateColumns="False">
     <ClientSettings>
         <Scrolling AllowScroll="True" UseStaticHeaders="True" />
         <Selecting AllowRowSelect="true" />
     </ClientSettings>
     <MasterTableView DataKeyNames="Course_Code" DataSourceID="sdsCourses">
         <CommandItemSettings ExportToPdfText="Export to PDF" />
         <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
             Visible="True">
         </RowIndicatorColumn>
         <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
             Visible="True">
         </ExpandCollapseColumn>
         <Columns>
             <telerik:GridClientSelectColumn Reorderable="False" UniqueName="ClientSelectColumn" HeaderText="Select">
             <HeaderStyle Width="50px"></HeaderStyle>
             </telerik:GridClientSelectColumn>
         <telerik:GridBoundColumn UniqueName="Course_Code" SortExpression="Course_Code" HeaderText="Code"
             DataField="Course_Code">
             <HeaderStyle Width="130px"></HeaderStyle>
             <ItemStyle HorizontalAlign="Left" />
         </telerik:GridBoundColumn>
          <telerik:GridBoundColumn UniqueName="Course_Title" SortExpression="Course_Title" HeaderText="Title"
             DataField="Course_Title">
             <HeaderStyle Width="200px"></HeaderStyle>
             <ItemStyle HorizontalAlign="Left" />
         </telerik:GridBoundColumn>
         <telerik:GridTemplateColumn FilterControlAltText="Filter column1 column" HeaderText="Expiration Date" UniqueName="column1">
             <HeaderStyle HorizontalAlign="Center" />
             <ItemStyle Width="120px" HorizontalAlign="Center" />
             <ItemTemplate>
                 <telerik:RadComboBox ID="rgTime" runat="server" Width="35px">
                     <Items>
                         <telerik:RadComboBoxItem runat="server" Text="1" Value="1" />
                         <telerik:RadComboBoxItem runat="server" Text="2" Value="2" />
                         <telerik:RadComboBoxItem runat="server" Text="3" Value="3" />
                         <telerik:RadComboBoxItem runat="server" Text="4" Value="4" />
                         <telerik:RadComboBoxItem runat="server" Text="5" Value="5" />
                         <telerik:RadComboBoxItem runat="server" Text="6" Value="6" />
                         <telerik:RadComboBoxItem runat="server" Text="7" Value="7" />
                         <telerik:RadComboBoxItem runat="server" Text="8" Value="8" />
                         <telerik:RadComboBoxItem runat="server" Text="9" Value="9" />
                         <telerik:RadComboBoxItem runat="server" Text="10" Value="10" />
                         <telerik:RadComboBoxItem runat="server" Text="11" Value="11" />
                         <telerik:RadComboBoxItem runat="server" Text="12" Value="12" />
                     </Items>
                 </telerik:RadComboBox>
                   
                 <telerik:RadComboBox ID="rgInterval" runat="server" Width="60px">
                     <Items>
                         <telerik:RadComboBoxItem runat="server" Text="Years" Value="Years" />
                         <telerik:RadComboBoxItem runat="server" Text="Months" Value="Months" />
                     </Items>                         
                 </telerik:RadComboBox>                           
             </ItemTemplate>
         </telerik:GridTemplateColumn>
         <telerik:GridTemplateColumn FilterControlAltText="Filter column2 column"
             HeaderText="Comments..." UniqueName="column2">
             <HeaderStyle Width="300px" HorizontalAlign="Left" />
             <ItemStyle HorizontalAlign="Left" />
             <ItemTemplate>
                 <telerik:RadTextBox ID="rtbComment" runat="server" TextMode="Multiline"
                     Height="63px" Width="290px" />
             </ItemTemplate>
         </telerik:GridTemplateColumn
         </Columns>
         <EditFormSettings>
             <EditColumn FilterControlAltText="Filter EditCommandColumn column">
             </EditColumn>
         </EditFormSettings>
     </MasterTableView>
     <FilterMenu EnableImageSprites="False">
     </FilterMenu>
     <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
     </HeaderContextMenu>
 </telerik:RadGrid>
 
 <asp:SqlDataSource ID="sdsCourses" runat="server"
     ConnectionString="<%$ ConnectionStrings:SafetyPlusWebConnectionString %>"
     SelectCommand="SELECT [Course_Code], [Course_Title], [Renewal_Interval], [Time_Frame] FROM [Courses] WHERE [Active] = 1 ORDER BY [Course_Code]">
 </asp:SqlDataSource>

Everything worked perfectly.  I could select and edit items at will.

But, I needed to get the selected items into a database.  I chose to put a radbutton below the grid for the user to click when they had made all their changes.

<telerik:RadButton ID="RadButton1" runat="server" Text="Next" OnClick="RadButton1_Click" ></telerik:RadButton>

When the button is clicked, I get the following:
Operation is not valid due to the current state of the object.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
[InvalidOperationException: Operation is not valid due to the current state of the object.]
   System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +83
   System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +111
   System.Web.HttpRequest.FillInFormCollection() +307
 
[HttpException (0x80004005): The URL-encoded form data is not valid.]
   System.Web.HttpRequest.FillInFormCollection() +404
   System.Web.HttpRequest.get_Form() +85
   System.Web.HttpRequest.get_Item(String key) +94
   Telerik.Web.UI.RadCompression.IsAjaxRequest() +59
   Telerik.Web.UI.RadCompression.Compress(HttpApplication application) +770
   Telerik.Web.UI.RadCompression.PreRequestHandlerExecute(Object sender, EventArgs e) +76
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +221
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +120
 
 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Any thoughts on how to correct this?

Thx
Richard
Top achievements
Rank 1
 answered on 24 Jan 2012
3 answers
127 views
Hello,

I am using telerik rad scheduler in our application. I want to scroll into view a specific time slot on initial page load for day view.
I have implemented all the necessary steps mentioned in the below link:-
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-scroll-into-view-a-specific-time-slot-on-initial-page-load.aspx

After implementing all the steps mentioned in above link, I am getting the below mentioned error.
"Microsoft JScript runtime error: Unable to get value of the property 'get_allowDelete': object is null or undefined"

Could you please let me know how to resolve this error.

Thanks and Regards,
Deepti
Plamen
Telerik team
 answered on 24 Jan 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?