Use the StartEdit method to switch the ASPxGridView to edit mode in code. End-users can do this by clicking the Edit command item displayed within the command column.
ImportsMicrosoft.VisualBasicImportsSystemImportsSystem.Web.UIImportsSystem.Web.UI.WebControlsImportsDevExpress.Web.DataImports DevExpress.Web.ASPxGridView
Imports DevExpress.Web.ASPxEditors
Imports DevExpress.Web.ASPxMenu
PartialPublicClass _Default
Inherits Page
Private processAddNewRow AsBooleanProtectedSub Page_Load(ByVal sender AsObject, ByVal e As EventArgs)
EndSubProtectedSub grid_DataBound(ByVal sender AsObject, ByVal e As EventArgs)
If (Not processAddNewRow) Then
grid.FilterExpression = ""
grid.StartEdit(grid.VisibleStartIndex)
Else
processAddNewRow = FalseEndIfEndSubProtectedSub grid_CellEditorInitialize(ByVal sender AsObject, ByVal e As ASPxGridViewEditorEventArgs)
If e.Column.FieldName = "ProductName"Then
e.Editor.SetClientSideEventHandler("Init", "ProductNameEditorInit")
EndIfIfTypeOf e.Editor Is ASPxTextBox Then
e.Editor.SetClientSideEventHandler("KeyDown", "TextBoxKeyDown")
e.Editor.SetClientSideEventHandler("KeyUp", "TextBoxKeyUp")
Else
e.Editor.SetClientSideEventHandler("ValueChanged", "EditorValueChanged")
EndIfEndSubProtectedSub grid_InitNewRow(ByVal sender AsObject, ByVal e As ASPxDataInitNewRowEventArgs)
processAddNewRow = True
grid.FilterExpression = "false"' This trick is required to hide all grid rows except for the new row's Edit Form.Dim menu As ASPxMenu = CType(grid.FindEditFormTemplateControl("editFormMenu"), ASPxMenu)
menu.Items.FindByName("miNew").ClientEnabled = False
menu.Items.FindByName("miDelete").ClientEnabled = False
menu.Items.FindByName("miRefresh").ClientEnabled = False
menu.Items.FindByName("miUpdate").ClientEnabled = True
menu.Items.FindByName("miCancel").ClientEnabled = TrueEndSubProtectedSub ProductsDataSource_Modifying(ByVal sender AsObject, ByVal e As SqlDataSourceCommandEventArgs)
ThrowNew Exception("Data modifications are not allowed in this online example.<br>" & "If you need to test the data editing functionality," & "please remove handlers of data modification events from your application's code.")
EndSubEndClass
If you have any questions, submit a ticket to our Support Center.
No
Your feedback is appreciated.
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
Privacy Preference Center
When you visit a Developer Express Inc (“DevExpress”) website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. While the information does not usually directly identify you, it can give you a more personalized web experience. Because DevExpress respects your right to privacy, you can choose to disallow/disable the use of certain cookies. Click on different category headings to learn more and change our default settings. Keep in mind that blocking some types of cookies may impact your experience on the site and may affect the services DevExpress is able to offer to you. You cannot opt-out of our use of strictly necessary cookies as they are used to ensure the proper functioning of our Websites (such as remembering your settings, allowing you to log into your account, and other similar purposes). You may, however, opt-out of receiving and our use of non-essential cookies (including preference, functional, and targeting cookies) by changing your settings for each category listed below.
[Videos]
Our use of cookies may also collect information about what videos you have watched on our websites. You may opt-out of these cookies by changing your settings for functional and advertising cookies. We will ask you to review and update your choices at least once every two (2) years. By continuing to allow us to use these cookies you explicitly consent to our use of cookies and our disclosure of what videos you have watched on our Websites to our video hosting providers, such as YouTube, for a period of up to two (2) years.
Manage Consent Preferences
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function properly and cannot be disabled. They are usually set in response to actions initiated by you – actions that amount to a request for services, such as setting your privacy preferences, logging onto the website, or populating website forms. You can set your browser to block or alert you about these cookies, but certain portions of the site will not work properly when these cookies are disabled. These cookies do not store any personally identifiable information.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand page popularity and determine how visitors move around the site. All information collected by these cookies are aggregated and therefore anonymous. If you disallow/disable these cookies, we will not know when you have visited our site and we will not be able to monitor its performance.
Functional Cookies
These cookies allow the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you disallow/disable these cookies, some or all of these services may fail to function properly.
Targeting Cookies
These cookies may be set through our site by our advertising partners. They may be used by advertising partners to build a profile of your interests and display relevant advertisements on other sites. While these cookies do not store personal information, they do identify your browser and internet device. If you disallow/disable these cookies, you will experience less targeted advertising.