Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Question using if() { } else {} in Repeater

Question using if() { } else {} in Repeater

Scheduled Pinned Locked Moved ASP.NET
helpquestiondockersecurity
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veroBT
    wrote on last edited by
    #1

    I have a repeater control which displays project information. I would like to check the security to ensure that the given user has access to the project he is trying to view. SO i'm tying to do so like this... <%# if(checkSubscribersRegions(Session["uid"].ToString(), DataBinder.Eval(Container.DataItem, "aut_projectID").ToString()) == "1") { %> display this stuff <% } else { %> display error <% } %> Here is the error i receive:

    Compiler Error Message: CS1513: } expected

    Can anyone help me out with this? Sincere Thanks, Brian

    C 1 Reply Last reply
    0
    • V veroBT

      I have a repeater control which displays project information. I would like to check the security to ensure that the given user has access to the project he is trying to view. SO i'm tying to do so like this... <%# if(checkSubscribersRegions(Session["uid"].ToString(), DataBinder.Eval(Container.DataItem, "aut_projectID").ToString()) == "1") { %> display this stuff <% } else { %> display error <% } %> Here is the error i receive:

      Compiler Error Message: CS1513: } expected

      Can anyone help me out with this? Sincere Thanks, Brian

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This is a patently bad idea. You should handle this in your code behind, and have your repeater just call a function. Inline code is one of the things that ASP.NET allows us to do away with. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      V 1 Reply Last reply
      0
      • C Christian Graus

        This is a patently bad idea. You should handle this in your code behind, and have your repeater just call a function. Inline code is one of the things that ASP.NET allows us to do away with. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        V Offline
        V Offline
        veroBT
        wrote on last edited by
        #3

        Thanks for the advice... My repeater is dealing with alot of data. Can you give me an example of your idea? (how you mean to implement this). Brian

        M C 2 Replies Last reply
        0
        • V veroBT

          Thanks for the advice... My repeater is dealing with alot of data. Can you give me an example of your idea? (how you mean to implement this). Brian

          M Offline
          M Offline
          Marcus_2
          wrote on last edited by
          #4

          <%# getMyStuff(Container.DataItem) %> In code behind public function getMyStuff( obj as object) as string { //get the data from the object, ie myString = obj.item("aut_projectID").ToString() if(checkSubscribersRegions(Session["uid"].ToString(), MyString) == "1") { return "display this stuff" } else { return "display error" } }

          C 1 Reply Last reply
          0
          • M Marcus_2

            <%# getMyStuff(Container.DataItem) %> In code behind public function getMyStuff( obj as object) as string { //get the data from the object, ie myString = obj.item("aut_projectID").ToString() if(checkSubscribersRegions(Session["uid"].ToString(), MyString) == "1") { return "display this stuff" } else { return "display error" } }

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Marcus_2 wrote: myString = obj.item("aut_projectID").ToString() Does this work in VB ? In C#, I'd need to cast the object to something useful before I could do anything like this. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

            M 1 Reply Last reply
            0
            • V veroBT

              Thanks for the advice... My repeater is dealing with alot of data. Can you give me an example of your idea? (how you mean to implement this). Brian

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              The aspx needs to be like the other guy said, but in C#, the code would look like this: System.Data.DataRowView oDataRowView = (System.Data.DataRowView) oDataGridItem; string item = oDataRowView.Row["ColumnName"].ToString(); etc. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

              1 Reply Last reply
              0
              • C Christian Graus

                Marcus_2 wrote: myString = obj.item("aut_projectID").ToString() Does this work in VB ? In C#, I'd need to cast the object to something useful before I could do anything like this. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                M Offline
                M Offline
                Marcus_2
                wrote on last edited by
                #7

                No actually it doesn't. You have to declare MyString somewhere (ie "dim myString as string = obj.item("aut_projectID").ToString()") and the function I wrote is a mess with both C# and VB code. I'm currently working in VB.NET so my head was there right then, and when I try to write this small snippets it's not actual code that will work, but more the general idea that has to be shown. Therefore MyString wasn't decalread and MyString isn't a name for a variable that I would use.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups