I'm new to Dynamic data I was wondering if anyone could please tell me how to create a new folder within the site directory after inserting a new row? I know how to create the folder using 'System.IO.Directory.CreateDirectory(path);' my only problem is getting
that to hit only after an insert.
Is it possible to achieve this without coding anything into the field templates or any other template?
I thought I had it working by using some of the partial methods such as onNameChanged() within my partial class, but that gets called regardless of whether your inserting, editing or deleting.
Hi mmokri, you can just handle the FormViews OnInserted even in the Insert page, if this is just for one table you could check the table name there. if this is because you are uploading files the I usually create a fiel upload field template see mine here
Dynamic Data Custom Field Templates
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
Could you please tell me how I would 'check the table name there'?
Hello:)
I don't think you can fetch the table name through the event here……And if you are using DD's Template,I think the current table name will be outputted automatically at the top of your page……Maybe you can right click your mouse to see the source of HTML codes,and
then use js or jQuery to save the table name in the HiddenField and take it out through the HiddenField。
Thanks for the info, I've found a way, perhaps it's not the best was by using the MetaTable object called table decalared at the top of the page, which has a Name property....
H there, it looks to me like he want some folders on the server for each record, not sure what he wants those folder for though. It looks like it is somthing very spcific for his use case.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
mmokri
Member
20 Points
7 Posts
After inserting a new row
Feb 26, 2012 10:30 AM|LINK
Hi guys,
I'm new to Dynamic data I was wondering if anyone could please tell me how to create a new folder within the site directory after inserting a new row? I know how to create the folder using 'System.IO.Directory.CreateDirectory(path);' my only problem is getting that to hit only after an insert.
Is it possible to achieve this without coding anything into the field templates or any other template?
I thought I had it working by using some of the partial methods such as onNameChanged() within my partial class, but that gets called regardless of whether your inserting, editing or deleting.
Any help would be really appreciated.
Thank you in advance
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: After inserting a new row
Feb 27, 2012 11:32 AM|LINK
Hi mmokri, you can just handle the FormViews OnInserted even in the Insert page, if this is just for one table you could check the table name there. if this is because you are uploading files the I usually create a fiel upload field template see mine here Dynamic Data Custom Field Templates
Always seeking an elegant solution.
mmokri
Member
20 Points
7 Posts
Re: After inserting a new row
Feb 27, 2012 11:48 AM|LINK
Hi sjnaughton, and thanks for the reply.
I'm not uploading files, my aim is to create a new folder structure for every 'theme' that gets inserted.
I was initially reluctant to add anything non generic into any of the action pages, but I think I may have to following your instruction.
I've found the event handler:
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) {
if (e.Exception == null || e.ExceptionHandled) {
Response.Redirect(table.ListActionPath);
}
}
Could you please tell me how I would 'check the table name there'?
Thanks again :)
venkatmca008
Participant
1810 Points
341 Posts
Re: After inserting a new row
Feb 27, 2012 11:52 AM|LINK
hi....can u post ur code...
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
mmokri
Member
20 Points
7 Posts
Re: After inserting a new row
Feb 27, 2012 11:56 AM|LINK
Hi venkatmca008,
Thanks for the info, although I know how to create a directory, I just require it to be created after an insert on a specific table
Thanks
mmokri
Member
20 Points
7 Posts
Re: After inserting a new row
Feb 27, 2012 12:00 PM|LINK
Yes I can...
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: After inserting a new row
Feb 28, 2012 12:26 AM|LINK
Hello:)
I don't think you can fetch the table name through the event here……And if you are using DD's Template,I think the current table name will be outputted automatically at the top of your page……Maybe you can right click your mouse to see the source of HTML codes,and then use js or jQuery to save the table name in the HiddenField and take it out through the HiddenField。
Plz correct me if I'm wrong。
Reguards!
mmokri
Member
20 Points
7 Posts
Re: After inserting a new row
Feb 28, 2012 08:38 AM|LINK
Hi Decker
Thanks for the info, I've found a way, perhaps it's not the best was by using the MetaTable object called table decalared at the top of the page, which has a Name property....
Which I wrapped inside an if statement like so...
if (table.Name.Equals("myTblName"))
{
//create directory
}
Regards
master_bait
Member
48 Points
39 Posts
Re: After inserting a new row
Mar 02, 2012 04:54 AM|LINK
I don't understand the original question
Yules
sjnaughton
All-Star
27391 Points
5485 Posts
MVP
Re: After inserting a new row
Mar 02, 2012 11:15 AM|LINK
H there, it looks to me like he want some folders on the server for each record, not sure what he wants those folder for though. It looks like it is somthing very spcific for his use case.
Always seeking an elegant solution.