locked
After inserting a new row RRS feed

  • Question

  • User-2109969872 posted

    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

    Sunday, February 26, 2012 6:30 AM

Answers

  • User-2109969872 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 28, 2012 4:38 AM

All replies

  • User-330204900 posted

    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

    Monday, February 27, 2012 7:32 AM
  • User-2109969872 posted

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

    Monday, February 27, 2012 7:48 AM
  • User-1344176646 posted

    hi....can u post ur code...

    Monday, February 27, 2012 7:52 AM
  • User-2109969872 posted

    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

    Monday, February 27, 2012 7:56 AM
  • User-2109969872 posted

    Yes I can...

    Monday, February 27, 2012 8:00 AM
  • User3866881 posted

    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。

    Plz correct me if I'm wrong。

    Reguards!

    Monday, February 27, 2012 8:26 PM
  • User-2109969872 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 28, 2012 4:38 AM
  • User1799985857 posted

    I don't understand the original question

    Yules

    Friday, March 2, 2012 12:54 AM
  • User-330204900 posted

    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.

    Friday, March 2, 2012 7:15 AM