Link to home
Start Free TrialLog in
Avatar of fruhj
fruhj

asked on

easy points - best way to modify select statement contained in the #region Web Form Designer generated code

Hey Experts-

   I'm working in asp.neet using c#

   my form has a select statement in the section:

   #region Web Form Designer generated code
   ...
   this.odbcSelectCommand1.CommandText = "SELECT LIST.* FROM LIST WHERE userID = 2";

   I need to alter the where statement programatically.

  Should I just mess with that string and build what I need, or is there another way of doing it that overrides the web form generated code -

  in otherwords, I know I can do something like
    this.odbcSelectCommand1.CommandText = "SELECT LIST.* FROM LIST WHERE userID = " + varUserId ;

  but what I need to know is - is this the best or "right" way to do it?
  for that matter I'm pretty new to ASP.net and C# - can I just specify the whole thing in my code? which would take precidence?

  I'm working on this right now -so if someone can give a good answer - you'll likely get the points today.

 - Jack


   

  Basically
SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fruhj
fruhj

ASKER

Thanks Guys (or Gals)

You guys gave me some alternate ways of putting the parameters in the querty - which is great stuff to know.

What I was really getting at (and probably was unclear about) is - should the Web Form Designer Code ever be modified? By default in VS2003, it's hidden and I have to click the '-' symbol to expand the section and see the code -that made me leary of modifying it - for fear that it could cause issues with the development IDE being able to recognize it's own code.

What I found was that I seem to be able to set the value twice - once in the web generated code using
this.odbcSelectCommand1....

and again in my if(!ispostback) block -
  just using
odbcSelectCommand1... (without the this)

I assume that the order of code execution is such that the if(!postback) loop occurs after the web form designer code

Thanks again for your responses!
Avatar of fruhj

ASKER

PS the system made me choose a single answer as the accepted one - however I am equally greatful to all 3 of you for your comments - I've upped the question value from 250 to 450 so a 3 way split works out to 150 each (600 each with an A weighting)