Display Insert Template on FormView when "Add New" button is clicked



I'm fairly new to working with ASP web controls, and am running into
what seems to be a ridiculous problem that I'm hoping will be a breeze
for an experienced ASP developer.

I have a GridView and a FormView on the same page, where the GridView
is visible at page load, and the FormView is set to Edit mode by
default, but is hidden on the page. I have the Select link enabled on
my GridView, and I use the SelectedIndexChanged event to hide the
GridView, update the SelectCommand on my datasource with the
SelectedIndex, and finally show the FormView. This all works
beautifully, and I get my FormView populated with the data from the
selected Index shown on the page.

The code to handle this is fairly simple, and looks like the following:
(with the bulk of the query removed for readability)
protected void GridView1_SelectedIndexChanged(object sender, EventArgs
GridView1.Visible = false;
FormView1.Visible = true;
dsPackageEdit.SelectCommand = "SELECT ... WHERE [ID] ="


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