Last post Jul 31, 2008 03:38 PM by McGuire
Jul 30, 2008 02:15 PM|McGuire|LINK
How do I change to edit mode programmatically using vb code? My edit button is not switching the record to edit mode and I get the error:
The ListView 'ListView1' raised event ItemEditing which wasn't handled.. I am using a similar edit button on several FormViews and they work fine. I cannot figure out why it is not working on the ListView. I have searched the Net for a couple days
without success for ideas on how to access using VB coding. Does anyone have any ideas? Thanks.
No records found.
Jul 31, 2008 02:25 AM|agolden|LINK
If your ListView is bound to a data source control (e.g. DataSourceID="myDataSource"), then clicking a button with CommandName="Edit" will put the ListView in Edit mode and bind the data automatically. If you're not using a data source control, as it appears
is your case, then the ListView doesn't know how to retrieve the data. In this case you'll need to handle the ItemEditing/ItemUpdating/ItemCancelling/etc events and do wire everything up manually. For the ItemEditing case, you'll need something list this:
protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
ListView1.EditIndex = e.NewEditIndex;
ListView1.DataSource = SomeData;
Hope that helps.
Jul 31, 2008 03:38 PM|McGuire|LINK
Just what I was looking for. Thanks. It is working now.
Also found another post that takes it a bit further for anyone who may need it: