Click to See Complete Forum and Search --> : Use variable from the code behind


skiabox
November 26th, 2008, 05:12 AM
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!

toraj58
November 27th, 2008, 05:47 PM
change this: <%=UserID %>

to

<%# UserID %>