FormView - initial template


D

David Thielen

Hi;

I call a page that has a FormView from 3 different buttons - view, edit, and
create. So I need to set the initial template when the page is called.

Is there a way to do this in the url for the page? Or if I have to do it in
it's code- behind, when/how?
 
Ad

Advertisements

S

Steven Cheng[MSFT]

Hi Dave,

As for the FormView, it has a "DefaultMode" property which can help us
specify the Mode/Template the FormView is about to display:

#FormView.DefaultMode Property
http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.formview.
defaultmode(VS.80).aspx

and for your scenario, you want to set the Mode according to a querystring
parameter on the page, I think we need to check the querystring value and
modify the FormView's DefaultMode property in the page's certain event. IMO
the "Page_Load" event should be the proper one:

e.g:

=========================
protected void Page_Load(object sender, EventArgs e)
{
string mode = Request.QueryString["mode"];

if (mode == "edit")
{

FormView1.DefaultMode = FormViewMode.Insert;

...............................
==================================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top