Kentico 7 Web part repeater SQL problem

Sanjin Tahirović asked on June 25, 2018 10:19

I have a Repeater set up on the page which is used to repeat Blog Posts. If the user clicks on the author a transformation is used to set ?author=[id] as a query parameter and lists all the blogs from that author. They reported a bug when adding ?author=dddd or any kind of string it throws an "Invalid column name "dddd" error". I've attached the web part properties and the error. Why is it throwing this sql exception ? http://prntscr.com/jyzlpu http://prntscr.com/jyzm7g http://prntscr.com/jyzmcn

Correct Answer

Jan Hermann answered on June 25, 2018 15:34

Please also change the Where condition macro to:

BlogPostAuthor = {% ToInt(QueryString.GetValue("author", ""), 0)|(identity)GlobalAdministrator%}

0 votesVote for this answer Unmark Correct answer

Recent Answers


Jan Hermann answered on June 25, 2018 10:40

How is the query string value passed to your repeater? Id on't see any macro within your web part configuration.

0 votesVote for this answer Mark as a Correct answer

Sanjin Tahirović answered on June 25, 2018 11:48

Im just recently on this project and as I know its passed by clicking on the author name, the rest is in the transformation <a href="?author=<%# Eval("BlogPostAuthor") %>"><%# BlogFunctions.GetAuthorName(Eval("BlogPostAuthor")) %>

http://prntscr.com/jz0tap

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 25, 2018 12:04

I understand the part how those links are generated, but somewhere (I would expect the Where condition property) the query string parameter should be processed by the repeater to know what author to render.

0 votesVote for this answer Mark as a Correct answer

Sanjin Tahirović answered on June 25, 2018 12:41

The where condition in the web part configuration is empty as you can see on the print scrn so its really confusing to know where does it filter the blogs by author

http://prntscr.com/jyzm7g

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 25, 2018 12:47

Isn't there any other repeater on that page? Finding the spot that it filters the author is crucial to find the root of your error.

0 votesVote for this answer Mark as a Correct answer

Sanjin Tahirović answered on June 25, 2018 14:28 (last edited on December 10, 2019 02:31)

Found it. There was a repeater hidden at the bottom called "Posts from single author". This is the where condition in the repeater configuration:

BlogPostAuthor LIKE {% QueryString.GetValue("author") |(identity)GlobalAdministrator%}

Is it possible to insert some macro which tests if QueryString.GetValue("author") is a number, if not just to return to homepage ? Because there are two more repeaters for year and month...

http://prntscr.com/jz30sl

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on June 25, 2018 15:07 (last edited on December 10, 2019 02:31)

It should be enough to set the visibility of that web part based on a number in that query string, so please click that small black arrow next to the Visible property and put following macro in there:

{% Convert.ToInt(QueryString.GetValue("author"), 0) > 0 |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Sanjin Tahirović answered on June 25, 2018 15:30 (last edited on June 25, 2018 15:34)

I've put the macro in the visibility, still have the same problem if i put directly in the url ?author=3jfhfhf or if i put author=334343 it returns the second error Incorrect syntax near ')'

http://prntscr.com/jz3xbz

And also get another error when there is no querystring

http://prntscr.com/jz3xv4

0 votesVote for this answer Mark as a Correct answer

Sanjin Tahirović answered on June 25, 2018 16:09

Yes, that seems to have done the job. Thank you.

0 votesVote for this answer Mark as a Correct answer

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