Problem: Usercontrol + Objectdatasource not updating parameters

T

timdelong1

I was writing a usercontrol in ASP.NET that contained an
objectdatasource, a gridview, and some other form controls (textboxes
and dropdown lists). For the insertcommand parameters I associated
them with the form controls by assigning the ID of each control. The
button event simply called the DataBind method on the Gridview.

If I then typed values into the form fields and clicked the button,
the insertparameter collection never updated itself based on the
values I just entered.

If I take this same code and paste it onto an aspx it works
perfectly. Each button click correctly checks the controls and takes
whatever value is present.

Thinking I may have done something elsewhere that was causing the
problem I created an entirely new project, recreated everything, used
only one form control (a single textbox named TextBox1) and the exact
same behavior was repeated.

Any thoughts? I know I must be doing something incorrectly here, but
I'm not sure what. When I was assigning a form control to the
associated FormParameter I was just entering the control name (ex.
TextBox1). The behavior displayed was almost like the datasource
couldn't find the form field.

Has anyone else encountered this problem, and if so, how did you fix
it?
 
T

timdelong1

After a good nights sleep I realized my mistake. I should have been
using ControlParameter instead of FormParameter. Changing that fixed
the problem quite nicely.
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top