Does anyone have any tricks for quickly laying out the asp.net html markup for a specific database table?
For example, say I have a table "Company", and I just want to render a textbox for all the columns.
One trick that I thought I saw and confirmed to work was to do some markup like so:
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
<p><label for="zzzz">zzzz</label><asp:TextBox ID="zzzz" Text='<%# Bind("zzzz")%>' runat="server" /></p>
Basically, one per row in your database table.
Then, select (in SQL Server):
select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'Company'
Highlight the COLUMN_NAME column in the resulting output and copy to clipboard.
Then, using the ALT+drag trick to highlight a vertical column, highlight the zzzz's in your markup (starting from the right so things keep lining up), and paste the column names over top. I swear I saw this done in a video, and I tried it myself and it worked, but tonight I can't seem to make it work.
Of course, an even better way to do this would be through T4 or some kind of code generation like that, and just have every table render default html into a folder such as \CodeGen\EditForms where you could copy and paste from, but for that I don't know where to start.
Update
Sure enough I figure the copy paste thing out as soon as I post a question.
The trick is to paste from SSMS into Visual Studio, then select the column names using the ALT+drag, then you can paste over top of the zzzz's.
So I guess that is solved. I would really love to see an example of how something better could be done with T4 though.