Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Assign command Name and in Event handler use code like this for editing and updating. I have used vb.net.</p> <pre><code>Create: Link Button b= new Link Button() cf.ShowEditButton = true; cf.CommandName="Edit"; gv.Columns.Add(cf); </code></pre> <p>Use Item Templates and Edit Templates.When edit command fire automatically rowediting method will be executed. </p> <pre><code>Protected Sub grdCustomers_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles grdCustomers.RowEditing grdCustomers.EditIndex = e.NewEditIndex GetAllCustomersData() End Sub </code></pre> <p>For Updating:</p> <pre><code>Protected Sub grdCustomers_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Dim result As Boolean Dim CustObj As New Services.Entities.Customers.Customer CustObj.CustomerID = DirectCast(grdCustomers.Rows(e.RowIndex).FindControl("lblCustomerId"), Label).Text CustObj.ContactName = DirectCast(grdCustomers.Rows(e.RowIndex).FindControl("txtContactName"), TextBox).Text CustObj.City = DirectCast(grdCustomers.Rows(e.RowIndex).FindControl("ddlCity1"), DropDownList).SelectedValue.ToString 'Type of binding Dim myBinding As New BasicHttpBinding 'Endpoint name defining Dim myEndPoint As New EndpointAddress(ConfigurationManager.AppSettings("CustomerServiceUrl").ToString()) Dim myChannelFactory As ChannelFactory(Of ICustomer) = New ChannelFactory(Of ICustomer)(myBinding, myEndPoint) 'Creating a Channel to access Services Dim client As ICustomer = myChannelFactory.CreateChannel result = client.UpdateCustomerDetails(CustObj) grdCustomers.EditIndex = -1 GetAllCustomersData() Sub End </code></pre> <p>For Canceling Update:</p> <pre><code>Protected Sub grdCustomers_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) grdCustomers.EditIndex = -1 GetAllCustomersData() End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload