?
Solved

Set detailsView currentmode after an update

Posted on 2010-01-08
2
Medium Priority
?
571 Views
Last Modified: 2013-11-07
I'm trying to figure out how to set the mode of a detailsView after I perform an update.  Right now everything works as far as clicking edit, altering a value, clicking update, and then seeing the new value but the detailsView is still in edit mode.  I've tried several different things but I just can't get it to revert back.  Please see attached code.

Thanks,

N
Protected Sub dvProjectDetails_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles dvProjectDetails.ItemCommand
    If e.CommandName = "Update" Then
        Dim projectDetailsAdapter As New ProjectDetailsAdapter
        Try
            projectDetailsAdapter.updateProjectDetails(sProjectID, sProjectTypeCode, sUserName)

        Catch exError As Exception
            lblErrorMessage.Text = "Error updating project details: " & exError.Message
            lblErrorMessage.Visible = True
        Finally
            projectDetailsAdapter = Nothing
        End Try
    End If
End Sub

<asp:GridView 
    ID="gvProjects" 
    DataKeyNames="ProjectID" 
    EmptyDataText="no records found"
    style="width:100%" 
    runat="server">
    <Columns>
        <asp:CommandField ShowSelectButton="true" ControlStyle-CssClass="btn" ButtonType="Button" ItemStyle-HorizontalAlign="center" />
        <asp:BoundField DataField="ProjectID" HeaderStyle-Width="0%" HeaderText="Project ID" SortExpression="ProjectID" ItemStyle-HorizontalAlign="center" visible="false" />
    </Columns>
</asp:GridView>

Open in new window

0
Comment
Question by:stretch73
2 Comments
 
LVL 8

Accepted Solution

by:
arhame earned 2000 total points
ID: 26212956
First, make sure the Detailsview default mode isn't in edit or insert - that will keep it in that mode permanently.

Second, try using this after your update:
dvProjectDetails.ChangeMode(Detailsviewmode.ReadOnly)
0
 

Author Closing Comment

by:stretch73
ID: 31674705
Got me there, thanks.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question