DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Use variable from the code behind (http://www.daniweb.com/forums/thread159563.html)

skiabox Nov 26th, 2008 5:10 am
Use variable from the code behind
 
I am using this variable from the code behind :




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

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

serkan sendur Nov 26th, 2008 8:44 am
Re: Use variable from the code behind
 
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.


All times are GMT -4. The time now is 3:18 am.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC