Hi,
I'm using AsyncUpload in a RadGrid
<
FormTemplate>.
When the User makes the changes to the record I want to Change the filename when it uploads it. The below works for the first row in the radgrid. When I try to update the second row I get object reference not set to an instance of an object.
Am i missing something?
Thanks
string
filenamenew =
string
.Empty;
GridEditFormItem editedItem = (GridEditFormItem)(gvContractors.MasterTableView.GetItems(GridItemType.EditFormItem)[0]);
RadTextBox txtcustomername = (RadTextBox)editedItem.FindControl(
"txtcustomername"
);
filenamenew = txtcustomername.Text.Replace(
" "
,
"_"
);
e.File.SaveAs(System.Configuration.ConfigurationManager.AppSettings[
"ContractorDatabaseUploads"
] + filenamenew +
"_Certificate"
+ e.File.GetExtension());
>
11 Answers, 1 is accepted
0
Hi Karl,
You code looks correct. On which line do you receive the exception. Can you paste here the stack-trace so that we can take a look at it?
Sincerely yours,
Genady Sergeev
the Telerik team
You code looks correct. On which line do you receive the exception. Can you paste here the stack-trace so that we can take a look at it?
Sincerely yours,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Karl
Top achievements
Rank 1
answered on 19 Jul 2010, 11:42 AM
Hi,
The attached is all I get, I can't view the stacktrace. I have an email function that sends emails when the
void Application_Error(object sender, EventArgs e)
{
}is hit, and nothing is fired. This works on everthing else
Any ideas?
0
Karl
Top achievements
Rank 1
answered on 22 Jul 2010, 08:13 AM
Hi,
Is this there anything else I can do to get this to work?
Thanks
Is this there anything else I can do to get this to work?
Thanks
0
Hello Karl,
You can obtain a full stack-trace if you temporarily disable the AJAX updates on the page.
If you're using RadAjaxManager set EnableAJAX to "false".
In case you're using update panels set EnablePartialRendering on the ScriptManager to "false":
We should be able to help with the full stack trace at hand.
You should also be aware that there's a known issue with the RadAsyncUpload in the official Q2 release. Our recommendation is to update to internal build 2010.2.722 before continuing.
I hope this helps.
Greetings,
Tsvetomir Tsonev
the Telerik team
You can obtain a full stack-trace if you temporarily disable the AJAX updates on the page.
If you're using RadAjaxManager set EnableAJAX to "false".
In case you're using update panels set EnablePartialRendering on the ScriptManager to "false":
<
asp:ScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
EnablePartialRendering
=
"false"
>
</
asp:ScriptManager
>
We should be able to help with the full stack trace at hand.
You should also be aware that there's a known issue with the RadAsyncUpload in the official Q2 release. Our recommendation is to update to internal build 2010.2.722 before continuing.
I hope this helps.
Greetings,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Karl
Top achievements
Rank 1
answered on 22 Jul 2010, 02:59 PM
Thanks, this is what I get:
Server Error in '/AppTest' Application.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Stack Trace:
Server Error in '/AppTest' 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:
|
Stack Trace:
|
0
Tojara
Top achievements
Rank 1
answered on 23 Jul 2010, 08:36 AM
In which event do you access the RadTextBox? I suppose that FindControl returns null instead of RadTextBox hence the exception. Here is an alternative approach:
void
Grid1_ItemCommand(
object
source, Telerik.Web.UI.GridCommandEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
string
filenamenew =
string
.Empty;
RadTextBox txtcustomername = (RadTextBox)editedItem.FindControl(
"txtcustomername"
);
filenamenew = txtcustomername.Text.Replace(
" "
,
"_"
);
e.File.SaveAs(System.Configuration.ConfigurationManager.AppSettings[
"ContractorDatabaseUploads"
] + filenamenew +
"_Certificate"
+ e.File.GetExtension());
}
}
0
Karl
Top achievements
Rank 1
answered on 23 Jul 2010, 09:05 AM
This is what I have,
I tried the way you suggested but it comes up with e.File does not exist which makes sense as e.File exists on the _FileUploaded Event.
Thanks
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
string
filenamenew =
string
.Empty;
GridEditFormItem editedItem = (GridEditFormItem)(gvContractors.MasterTableView.GetItems(GridItemType.EditFormItem)[0]);
RadTextBox txtcustomername = (RadTextBox)editedItem.FindControl(
"txtcustomername"
);
filenamenew = txtcustomername.Text.Replace(
" "
,
"_"
);
e.File.SaveAs(System.Configuration.ConfigurationManager.AppSettings[
"ContractorDatabaseUploads"
] + filenamenew +
"_Certificate"
+ e.File.GetExtension());
}
I tried the way you suggested but it comes up with e.File does not exist which makes sense as e.File exists on the _FileUploaded Event.
Thanks
0
Tojara
Top achievements
Rank 1
answered on 23 Jul 2010, 10:23 AM
I believe that this is issue with RadGrid. I am not sure if it is possible to access controls that are in edit form outside of the Grid context.
0
Karl
Top achievements
Rank 1
answered on 23 Jul 2010, 01:17 PM
Any ideas on how I can achieve what I want?
0
Accepted
Tojara
Top achievements
Rank 1
answered on 23 Jul 2010, 02:18 PM
If I were you, I would use the RadAsyncUpload.UploadedFiles collection. You can use it to access the uploaded files outside of the FileUploaded event. First file in the collection is from the first input, second from the second and so on. You can it inside the ItemCommand event of RadGrid.
0
Karl
Top achievements
Rank 1
answered on 26 Jul 2010, 01:29 PM
Thanks, that worked. If any one else is interested :
used this sample and post for ref :
http://www.telerik.com/community/forums/aspnet-ajax/upload/radasyncupload-not-to-save-to-file-location.aspx
used this sample and post for ref :
http://www.telerik.com/community/forums/aspnet-ajax/upload/radasyncupload-not-to-save-to-file-location.aspx
IList<UploadedFile> files;
protected
void
Page_Load(
object
sender, EventArgs e)
{
files =
new
List<UploadedFile>();
}
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
files.Add(e.File);
}
//Add this in your Update and Insert
foreach
(UploadedFile test
in
files)
{
test.SaveAs(System.Configuration.ConfigurationManager.AppSettings[
"MyPath"
] + filenamenew +
"_Certificate"
+ test.GetExtension().ToString());
}