dodgerfan
asked on
Open form to insert new record.
I have a gridview on a form that displays records. Next to each record is a Edit button. When this button is clicked, another form pops up to allow editing of that record. The form that pops up is another asp.net form with a asp:FormView control on it to display a record. I would like to have another button outside of the gridview that will open up the same popup form to insert a new record. So the popup form needs to open up to blank fields. The formview on that form has the EditItemTemplate, ItemTemplate and InsertItemTemplate on it. By defualt I set it to open up in Edit Mode. How can I get my button to open it in Insert Mode? Thanks.
Hello, you can use the FormView.DefaultMode property to accomplish that, example:
<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert">
.....
</asp:FormView>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
yv989c:
That looks lke exactly what I'm looking for. I'll ive it a shot tomorrow. Thanks.
That looks lke exactly what I'm looking for. I'll ive it a shot tomorrow. Thanks.
Hello, it is very easy to open the blank form into the click event of any button. You have to use the btn.Attributes.Add("OnClic k","Value" ) through the javascript for open the form in popup window.
ASKER
Perfect, again. Thanks.
Glad to help
the method looks like this:protected void GridView1_RowUpdating(obje
{
TextBox txtName = (TextBox)GridView1.Rows[e.
TextBox txtCity = (TextBox)GridView1.Rows[e.
//Your updation query pass the values like set city=' "+txtCity.Text+" '
GridView1.EditIndex = -1; //converts to normal mode from edit mode
// If having any bind method call here to see the updated rows
BindData();//(in this method write binding datasource to GridView1)
}