Click here to Skip to main content
15,074,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I edit a selected row of dataGrid in WPF.

I have a NewEntry button on my window. When user click on NewEntry button, a new window is open with a form.After filling this form when I click the save button all information are shown in datagrid.I have done it using WPF. Now I need to edit specific row. there is a modify button on my window. I wish that,user select a row by click his mouse, then he can edit this row by click modify button. How can I shall do it. please give me a suggestion. Give me some example code.

I already do it in a web application. But I don't know syntax for desktop.

these are my sample code of web application. Please Give a similar way if possible
C#
protected void Edit(object sender, EventArgs e)
        {
            try
            {
                _shiftManager = new ShiftManager();
                _shift = new Shift();

                int index = (((GridViewRow)(((LinkButton)(sender)).Parent.BindingContainer))).RowIndex;
                var shiftId = ((Label)gvShift.Rows[index].Cells[0].FindControl("lblCode")).Text;
                _shift = _shiftManager.GetShift(shiftId);
                FillShiftInformation(_shift);
                ViewState["_isNew"] = false;

                txtShiftCode.Enabled = false;

            }
Posted
Updated 21-Mar-13 8:38am
v2

1 solution

There's a nice article about that here[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900