How to enable Edit in DetailsView control with custom code to handle the event?

Hi, I'm using VS2013, asp.ent web form and c#
In this DetailsView contorl, it's bind to a database(my code created the columns and the table)  that I created the source is from a class object I retrieve using a web service.  So there is no sql data command that I can configure for it.  
When user click the Update button, how can I make the details view data turn into text box so users can edit the information?  I followed the example here, http://stackoverflow.com/questions/13380697/trapping-edit-update-events-from-detailsview-button-clicks,  but not sure how to do this part.
Also, how can I get all the modified data to use my code to update via web services.  Is there any indication of what's modified or do I have to update entire fields?
Thank you.
lapuccaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
What have you come up with for the ItemCommand?

asp:DetailsView ID="DetailsView1" runat="server"  
    OnItemCommand="DetailsView1_ItemCommand"
    <Fields>
       <asp:BoundField  DataField="IdField" HeaderText="ID" />
       <asp:BoundField  DataField="NameField" HeaderText="Name" />
       <asp:ButtonField CommandName="Add" Text="Add Something" />
       <asp:ButtonField CommandName="Edit" Text="EditSomething" />
       <asp:ButtonField CommandName="Delete" Text="Delete Something" />
    </Fields>
</asp:DetailsView>

in codebehind:

rotected void DetailsView1_ItemCommand(object sender, System.Web.UI.WebControls.DetailsViewCommandEventArgs e)
{
      switch (e.CommandName) {
            case "Add":

                  break;
            case "Edit":

                  break;
            case "Delete":

                  break;
      }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lapuccaAuthor Commented:
I only want Edit and Update buttons.  When User hits Edit button i would like the grid to be in Editable form, How to do this?  When user clicks the update mode, I would process the data and then how to change the grid back to read only mode?

Also, to show Edit and a Cancel button when loaded.  And then in Edit mode to show a Update and a Cancel button.  How to switch this?

my cod is about the same as you have it.  
            <Fields>
                <asp:TemplateField ShowHeader="False">

                    <EditItemTemplate>
                        <asp:Button ID="ButtonUpdate" runat="server" CausesValidation="True"
                            CommandName="Update" Text="Update"  />
                        &nbsp;<asp:Button ID="ButtonCancelUpdate" runat="server" CausesValidation="False"
                            CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>

                    <ItemTemplate>
                        <asp:Button ID="ButtonEdit" runat="server" CausesValidation="False"
                            CommandName="Edit" Text="Edit" />
                         &nbsp;<asp:Button ID="btnEditCancel" runat="server" CausesValidation="False"
                            CommandName="Cancel" Text="Cancel" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Fields>

        protected void dvProtocol_ItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            DetailsViewRow dvr = dvProtocol.Rows[0];

            switch(e.CommandName)
            {
                case "Update": break;
                case "Edit":
                           
                            break;
                default: break;
            }        

        }

Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.