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

[Solved] Grid / Attachment column Demo Error

7 Answers 236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 02 Feb 2010, 04:37 AM
Folks,

Environment: RadControls for ASP.NET AJAX Q3 2009 / VS 2008 SP1/IE7/WINXP SP 2.

I was working in the below Link. After clicking the Edit Command, I got the attached error. This error I received with the Rad Controls installed in my local work station. Any help will be appreciated. Thanks
 
gc_0620

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/gridattachmentcolumn/defaultcs.aspx

7 Answers, 1 is accepted

Sort by
0
gc_0620
Top achievements
Rank 1
answered on 02 Feb 2010, 04:49 AM
Also Please note: I can't update the existing file with a new one in Edit Mode. The Upload control is not available. This attached File related to this issue is from Telerik Site Demo. Thanks...
0
gc_0620
Top achievements
Rank 1
answered on 04 Feb 2010, 01:23 AM
Any feedback in this Issue. I need to upload files (.DOC/XLS/.PDF formats) via Radgrid into a SQL 2005 Table and allow users to view the uploaded attachment file in the screen if they double click on that Grid Column (i.e. The link to that attachment file).. 

Thanks
0
Accepted
Veli
Telerik team
answered on 05 Feb 2010, 12:59 PM
Hello gc_0620,

Thanks for reporting this. I was able to reproduce the exception. Currently, I reproduce it on the online demos only, even though my local copy is identical to the online version.

I am going to need some more to research this issue. Let me get back to you whenever I find something.

Sincerely yours,
Veli
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Accepted
Veli
Telerik team
answered on 09 Feb 2010, 02:50 PM
Hi gc_0620,

This problem originates from RadDateTimePicker that is loaded in RadGrid's edit form. Particularly, the TimeView control (used to pick time) has issues with AJAX being disabled to upload some attachment. The problem is reproduced after you insert or update an item with an attachment, and then open the edit form again. The issue is currently not reproducible locally, but on the live demos only, so I believe it is about some time-dependent issue that requires a longer response delay.

Currently, workarounds are to use DatePicker (without the time view), or, alternatively, not disable AJAX on postback.

All the best,
Veli
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
gc_0620
Top achievements
Rank 1
answered on 09 Feb 2010, 06:39 PM
Thanks Veli

I really appreciate your attention to this matter and get back to me with your findings and recommendations.  As per your suggestion, I am implementing to use DatePicker (without the time view). Hopefully the future releases of Telerik Product, this issue will be fixed.

I really do not need Time picker in Upload because in my RadGrid I have a column name "Last Update Date/Time". Any changes to Grid, I update that column with Current Date/Time. 

One final question for your recommendation:  1) Is it advisable to upload the BinaryData into SQL 2005 database or 2) Just the path name of the uploaded file and make a referrence to uploaded file? I am thinking about the performance issue.

This project we are developing is for HR department, where other department heads will enter the potential employees data of their own departments into grid and attach documents such as resume, extracredentials etc.. and submit to HR. For each employee, the combined attachments might be as large as 5MB although the single attachment is limit to 1 MB.  Any Telerik article that discusses the con and pro of both methods will be highly appreciated.  

Sincerely,

gc_0620
0
Accepted
Veli
Telerik team
answered on 10 Feb 2010, 09:08 AM
Hello gc_0620,

Even though we do not have a ready article that discusses the two approaches, we can discuss them here right now :)

Generally, both of the approaches follow one and the same logic up to some point. For both types, you need to upload the file to the server first, so performance is the same up to the point the data is uploaded.

From here, you can either save the data to a physical file in a folder, or save them in a field in SQL Server. Thus, the performance difference is the difference between saving equally long binary data to SQL and to a file. I expect the SQL insertion to be slower than simple file write.

Still, keeping attachment in SQL server has a couple of advantages -> easier data backups and deployment, easier migration to another server (moving only the database vs moving files and folders), as well as an increased robustness - the data is kept as a consistent set of records containing both file data and meta data, vs keeping separate SQL records and physical files that may get deleted or moved accidentally.


Regards,
Veli
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
gc_0620
Top achievements
Rank 1
answered on 10 Feb 2010, 04:35 PM

Thanks again Veli.

We will go SQL Data insertion route. Although it may be little slower but will be easier to maintain and Transport in the event of Database Server failure. Also there will be no chances for accidental deletion of Physical attachment File.

We tried out the Grid Attachment Demo. Only question is we would like to hide this column while in edit/insert mode.  In the demo, FileName and Upload File is the same in the Grid. We just need to show one column.

 

<telerik:GridBoundColumn DataField="FileName" HeaderText="FileName" > 
</telerik:GridBoundColumn> 
 
 

 

 

 

 


One choice we were thinking to convert that column into a Template column.  So that in EditItemTemplate we can make it visible = "false". Below is what we did.

 

<telerik:GridTemplateColumn DataField="FileName" HeaderText=" Template FileName"   
                        UniqueName="FileName">  
                        <EditItemTemplate> 
                            <asp:TextBox ID="FileNameTextBox" runat="server" Text='<%# Bind("FileName") %>' visible = "false"></asp:TextBox> 
                        </EditItemTemplate> 
                        <ItemTemplate> 
                            <asp:Label ID="FileNameLabel" runat="server" Text='<%# Eval("FileName") %>'></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

By doing this we got this error message:

________________
 

Server Error in '/Live Demos' Application.

Object reference not set to an instance of an 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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 63: 
Line 64:                  
Line 65: string fileName = (item.EditManager.GetColumnEditor("FileName") as GridTextBoxColumnEditor).Text;Line 66:                 
Line 67:                 

Source File: c:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2009\Live Demos\Grid\Examples\GeneralFeatures\GridAttachmentColumn\DefaultCS.aspx.cs    Line: 65 
___________________
 
Below is our modifed RadGrid1_ItemCommand. It works if we use  column FileName as GridBoundColumn, but by doing that how do we hide it in edit/insert mode?

 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
        {  
              
            if (e.CommandName == RadGrid.UpdateCommandName ||  
                e.CommandName == RadGrid.PerformInsertCommandName)  
            {  
                GridEditableItem item = e.Item as GridEditableItem;  
                   
 
 
                if (!(item is GridEditFormInsertItem))  
                {  
                    fileId = (int)item.GetDataKeyValue("ID");  
 
                }  
 
                                  
              string fileName = (item.EditManager.GetColumnEditor("FileName") as GridTextBoxColumnEditor).Text;  
                  
                  
                fileData = (item.EditManager.GetColumnEditor("AttachmentColumn") as GridAttachmentColumnEditor).UploadedFileContent;  
 
                if (fileData.Length == 0 || fileName.Trim() == string.Empty)  
                {  
                    e.Canceled = true;  
                    RadGrid1.Controls.Add(new LiteralControl("<style='color:red;'>No file uploaded. Action canceled.</b>"));  
                }  
            }  
        } 


Appreciate for all your help.

 

Sincerely.

 

gc_0620

Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
gc_0620
Top achievements
Rank 1
Veli
Telerik team
Share this question
or