Use variable from the code behind

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2007
Posts: 4
Reputation: skiabox is an unknown quantity at this point 
Solved Threads: 0
skiabox skiabox is offline Offline
Newbie Poster

Use variable from the code behind

 
0
  #1
Nov 26th, 2008
I am using this variable from the code behind :




  1. public string UserID; //globally declare the UserId
  2. protected void RadGrid1_PreRender(object sender, EventArgs e)
  3. {
  4. MembershipUser myObject = Membership.GetUser();
  5. UserID = myObject.ProviderUserKey.ToString();
  6. }

I am trying to use the variable in the INSERT command in the aspx file but it seems that the following command does not work,any ideas why?

InsertCommand="INSERT INTO table (column1, column2) VALUES (value1, '<%=UserID %>')"


Thanks!
Reply
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Use variable from the code behind

 
0
  #2
Nov 26th, 2008
it seems ok, but if i were you, i would create a class for data access, and create 4 methods to select insert update and delete data, then use objectdatasource object to use those methods, so you dont have to bother with aspx and code behind thing. there is a good video tutorial on asp.net as to how to use objectdatasource efficiently.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC