Hello,
I have a page "xxList.aspx" which lists all the records in table "Domains" with a "ViewDetails" link which takes the users to a detailed FormView of that specific record - "xxAddEdit.aspx" and they can edit the record there (having Upadte and Cancel) buttons. The First Page "xxList.aspx" also gas a "AddNew" button if the users want to add a new record.
The default mode for my FormView is "Edit" To make that AddNew button work I added the following code on thePage_Load event of "xxAddEdit.aspx"
If
(Not IsPostBack)ThenIf (FormView1.PageCount = 0)ThenFormView1.ChangeMode(FormViewMode.Insert)
EndIfEndIfNow, it loads the page for inserting a new record. But if I click on the "ViewDetails" link on the first page i.e. xxList.aspx", it doesn't show the record details. Instead it opens up ready to insert a new record.
Please suggest how to tackle this.
Hi friends,
I got this working. Thanks to a post on Google Groups. This is what I did -
Protected
Sub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.LoadDim sidIf (Not IsPostBack)Thensid = Request.QueryString(
"Id")If (sid ="")ThenFormView1.DefaultMode = FormViewMode.Insert
ElseFormView1.DefaultMode = FormViewMode.Edit
EndIfEndIfEndSubBut, I have another problem now. Once I am in the insert mode and click the "Insert" button after entering in the values for new record, it throws me an error saying -
>FormView 'FormView1' must be in edit mode to update a record.
I have tried setting the formView mode back to Edit on the insert button's click event. Its like -
Protected
Sub Button3_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)FormView1.DefaultMode = FormViewMode.Edit
EndSub
But, this doesn't work. Can somebody please help? Thanks.
0 comments:
Post a Comment