db update via web form

  • Thread starter Thread starter epigram
  • Start date Start date
E

epigram

I'm using a web form that I am populating from a query (via a
SqlDataReader).
This isn't a datagrid or other similar control, its simply a series of
TextBox controls on a page. Most of the examples I have seen thus far have
been dealing with using datagrids, etc. and how asp.net can help you deal
with updates in a somewhat automatic fashion. I have what I consider a more
traditional form (which may mean I am doing this wrong) and my db update is
somewhat complicated because depending on which TextBox's text has changed I
need to perform different update logic.

Most of the updates I have seen have happened in the Page_Load event, but
that doesn't seem appropriate here. I know that I can have event handlers
that get called for every text control but those happen after Page_Load.
What I feel I need to do is in Page_Load determine which TextBox controls
have changed, and then perform the appropriate update logic. Any help would
be much appreciated.
 
Hi,
Something has to trigger the postback of the page right? If it is a button,
why not use the click event to test which text box has changed and then
execute the appropriate update. For the update you can use SQL or
OleDbCommands attached to stored procedures.

Ian
 
Yes a postback will occur because of a button being pressed. The part
(which I am sure is ridiculously simple) is how to tell if a given control
has changed without caching it's original value in a dataset, session
variable, etc. Maybe that is exactly what you do. Maybe you use the
ViewState somehow. I just don't know. In the examples I have been viewing
you know that a control has changed by an on change even for the control
being called.

Thanks!
 

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

Back
Top