|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Intercepting the DataGridI'm using an ObjectDataSource with a GridView. Is there an event, either in
the ObjectDataSource or teh GridView, that will let me intercept the datasource before the GridView renders so that I can add a row? I've tried playing with the DataBinding and DataBoud events, but I can't seem to get into the datasource in those events. I'm trying to implement some AddNew functionality to the GridView and I figured I could respond to a button click and add a blank row to the datasource and throw it into edit mode immediately. But how? I've been searching for ways to implement add or insert functionality on the GridView, but haven't found anything that was slick enough to rely on. Thanks. Jerry How about subclassing GridView and add your row within OnDataBound by
overriding the superclass' method. This new row should contain the 'Insert' button that raises an insert event. Handle the insert event by writing you own OnRowInserting handler. Hi Jerry,
As for the Gridview control, it is template databound control , so its data items(displayed) can not be added on the fly, the only means to add an additional row is modify the underlying datasource bound to the GridView control. For the ObjectDataSource, it hasn't provided built-in interfaces for adding additional rows to the underlying datasource(we can only perform some filtering on the recordset). IMO, such modification should be done at the DataAccess component class level, we can create a custom wrapper class to encapsulate the original data access class(configured in ObjectDataSource). For example, we can create a custom wrapper class, its data select method simply call the original data component's Select method and do some additional customization on the returned datasource(add a row or ...). Please feel free to let me know if your have any other consideration or idea. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
GridView TemplateColumn
Retrieving Values from Hidden Fileds Inside Web Controls on PostBa Accessible GridView Intercepting the GridView Panel Controls ASP.NET datagrid System.Web.UI.WebControls.Image control not refreshing PREVENT an ASP.Net page from posting back when the ENTER key press Reaching elements within <asp:formview> control Postback and return view |
|||||||||||||||||||||||