how to get item information from custom table by query string

john martin asked on August 28, 2017 16:45

I would like to get itemID from query string and get name of item from custom table like http://www.abc.com?itemid=123. how can i use below macro expression to get from querystring?

{%GlobalObjects.CustomTables["customtable.tableName"].Items.Where("ItemID=123")("itemName")#%}

I tried this way but not succeeded: {%GlobalObjects.CustomTables["customtable.tableName"].Items.Where("ItemID={?itemid?}")("itemName")#%}

Recent Answers


Zachary Perry answered on August 28, 2017 17:30 (last edited on August 28, 2017 21:01)

Try something like this: {%GlobalObjects.CustomTables["customtable.tableName"].Items.Where("ItemID="+ QueryString.GetValue("itemID"))("itemName")#%}

Edit: Be warned you are passing in a querystring value into a where condition in a query, I believe SQL injection will be handled in this case, but might want to double check.

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on August 28, 2017 20:54

Are you going to use this in portal engine or in the .NET code?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.