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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.