R
Rickard Andersson via .NET 247
I'm using a DataGrid to display and edit entries from a databasetable called Contacts. I've completed the MSDN document"Walkthrough: Using a DataGrid Web Control to Read and WriteData" and it's working out fine. My SQL select command lookslike this:
SELECT Id, Name, Phone, Email FROM Contacts
Now I want to restrict that query to only display entries with acertain OrganizationId. The OrganizationId I want to use can befound in Session["OrganizationId"]. I basically want this:
SELECT Id, Name, Phone, Email FROM Contacts WHERE OrganizationId= THE_ID_FROM_THE_SESSION
What I'm asking is how I should do this. I've tried editing thesqlSelectCommand manually in "Web Form Designer generated code"that was generated for me by the SqlDataAdapter wizard, but if Ieven touch that code, VS.NET freaks out and removes theCommandText property completely (and then I am unable to re-addit!). I guess I could add it via the properties for theSelectCommand for the SqlDataAdapter in design mode, but I can'tsee how to add dynamic data such as a session variable in thattextbox. What am I missing/doing wrong?
SELECT Id, Name, Phone, Email FROM Contacts
Now I want to restrict that query to only display entries with acertain OrganizationId. The OrganizationId I want to use can befound in Session["OrganizationId"]. I basically want this:
SELECT Id, Name, Phone, Email FROM Contacts WHERE OrganizationId= THE_ID_FROM_THE_SESSION
What I'm asking is how I should do this. I've tried editing thesqlSelectCommand manually in "Web Form Designer generated code"that was generated for me by the SqlDataAdapter wizard, but if Ieven touch that code, VS.NET freaks out and removes theCommandText property completely (and then I am unable to re-addit!). I guess I could add it via the properties for theSelectCommand for the SqlDataAdapter in design mode, but I can'tsee how to add dynamic data such as a session variable in thattextbox. What am I missing/doing wrong?