OK, so probably not the best use of my time today, but I whipped this out:
It almost works, and some of the code isn't terrible. The goal was, type in a mysql table name and hit "Go". You get a field list of the table. Map each field to your desired HTML control and click "Generate Data."
It will then generate the html code for a form based on your dropdown selections. Labels are optional (uncheck if you don't want them), and you can generate required field labels by checking "Req." You can also change the label's value if you don't want it to the be the same as the field name.
You can check HTMLEncode to make some copy/paste friendly code.
So, this is not connecting to a db for the above link. I just hard coded a DataTable in it. Also, not every single input type may be working correctly.
The one thing that bugs me is, when connected to the db, it gets the field list like this:
MySqlDataAdapter myAdapter = new MySqlDataAdapter("SHOW COLUMNS FROM " + TableName + "", conn);
The gridview rows are actually sortable now via drag and drop (using jquery). But it doesn't store anything anywhere, so when it posts back to generate the html controls, it loses the sort.
Anyone have any thoughts on a simple way to keep the sort order of the gridview on post back?
I have a few thoughts, but they are not simple.
Note: This was for local use. Yes, I know that query is vulnerable to SQL injection. I also don't mind pasting some code on github.
Thanks,
It almost works, and some of the code isn't terrible. The goal was, type in a mysql table name and hit "Go". You get a field list of the table. Map each field to your desired HTML control and click "Generate Data."
It will then generate the html code for a form based on your dropdown selections. Labels are optional (uncheck if you don't want them), and you can generate required field labels by checking "Req." You can also change the label's value if you don't want it to the be the same as the field name.
You can check HTMLEncode to make some copy/paste friendly code.
So, this is not connecting to a db for the above link. I just hard coded a DataTable in it. Also, not every single input type may be working correctly.
The one thing that bugs me is, when connected to the db, it gets the field list like this:
MySqlDataAdapter myAdapter = new MySqlDataAdapter("SHOW COLUMNS FROM " + TableName + "", conn);
The gridview rows are actually sortable now via drag and drop (using jquery). But it doesn't store anything anywhere, so when it posts back to generate the html controls, it loses the sort.
Anyone have any thoughts on a simple way to keep the sort order of the gridview on post back?
I have a few thoughts, but they are not simple.
Note: This was for local use. Yes, I know that query is vulnerable to SQL injection. I also don't mind pasting some code on github.
Thanks,