DAL and Gridview

T

Tim Tafflinger

I've created a DAL and can use the methods to load and manipulate data in a
gridview when it is bound to an objectdatasource. But I've been told with a
DAL I don't need an objectdatasource at all but I'm having difficulty
figuring out how to do it. Loading the data in the gridview is no problem,
it's the updating and deleting that won't work. When I click on the Edit or
Delete buttons I get an unhandled event error so apparently I need to use
those events somehow but haven't been able to figure it out and all the
examples I can find use an objectdatasource. Can someone point me in the
right direction?
 
J

Jonathan Wood

If you use the wizards, you still have access to the data source's Update,
Insert, and Delete commands (in addition to the select commands). Of course,
you'll need to select the appropriate methods on your object for each
command and ensure the proper arguments are being supplied.

If you don't want a data source control, just set the GridView's DataSource
property in your page's Load event and call DataBind.
 
T

Tim Tafflinger

I used the wizards to create the DAL and specified the sprocs for the CRUD
procedures and it all works great with the objectdatasource. With no data
source control at all I am able to do just what you said and bind to the
gridview on the page load event. But when I click the Edit link button in
the grid I get an "The GridView 'GridView1' fired event RowEditing which
wasn't handled" error. So it seems obvious that in the RowEditing event I
need to set up the gridview for editing then there is probably a RowUpdating
event that where I need to access the methods in my DAL to do the update but
I just haven't been able to figure it out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top