Auto-create formview templates

Is there a way to auto create the edit item and insert new item templates for a formview?
At present I am faced with creating a 2 column table with 12 rows and binding the controls to the fields....and then doing it again for the insert new item.

Is there no way to auto create the item templates based on the underlying SQL in the data source?

VS2010 c#
LVL 29
QPRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dejaanbuCommented:
The Formview templates for view, insert, edit can be auto-generated if you are assigning the SQLDatasource in design mode. its all generated automatically.

the only thing is,  you have to change the layout (inside a Table as you said) or design of Edit/View/Insert templates of the formview using the smarttag in design view.

examples:

http://www.dotnetfunda.com/articles/show/991/formview-in-edit-insert-readonly-mode
http://www.siue.edu/~dbock/cmis460/Module%2015%20--%20FormView%20Control/Module15-FormView.htm
0
QPRAuthor Commented:
I must be missing something? I added a FV to the page and added a sqlsatasource - I specify that the select parameter come from the query string. I test it and a record is returned. Then when I click ok the FV is shown but all templates are empty.
I fire up my site and browse to the FV page but the page is empty.
0
dejaanbuCommented:
not sure about the cause:

make sure you have emptydatatemplate for the formview.


also check your formview's default mode in properties window.

you could check whether the formview has data by adding a databound code to the formview:

urFormView_Databound (ByVal sender As Object, ByVal e As EventArgs) Handles urFormView.DataBound
{
    If urFormView.DataItemCount = 0 Then
        urFormView.ChangeMode(FormViewMode.Insert)
    Else
        urFormView.ChangeMode(FormViewMode.Edit)
    End If
}

Open in new window


the one more example for you:
http://howtouseasp.net/formview-in-asp-net-ado-net-way-c/
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

QPRAuthor Commented:
I had to delete the whole thing and start again, this time I did get the templates!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dejaanbuCommented:
ok..Glad you have solved it urself
0
QPRAuthor Commented:
Had to rebuild
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.