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. DataGrid WebServer Control - Dynamically change the edititemstyle

DataGrid WebServer Control - Dynamically change the edititemstyle

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdesignhelptutorial
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.
  • R Offline
    R Offline
    RickardB
    wrote on last edited by
    #1

    I am writing a ASP.NET application with a UI based on the DataGrid WebServer Control. The user is able to write back data do the system by clicking on the edit-button in the first column of the datagrid. However, the user is not always allowed to write back data in alls columns, this depends on his/hers priveleges. Example, lets say the datagrid have three columns plus the edit column: edit col1 col2 col3 And the active user only has permissions enough to edit col1 and col3. When this user press the edit button only the cells in col1 and col3 should display textboxes that allow the user to enter a value. How can this be implemented? I have understood that I should to it in the ItemCreated eventhandler. But I haven't figured out how do it exactly yet. Anyone who can help me? /Rickard

    M S 2 Replies Last reply
    0
    • R RickardB

      I am writing a ASP.NET application with a UI based on the DataGrid WebServer Control. The user is able to write back data do the system by clicking on the edit-button in the first column of the datagrid. However, the user is not always allowed to write back data in alls columns, this depends on his/hers priveleges. Example, lets say the datagrid have three columns plus the edit column: edit col1 col2 col3 And the active user only has permissions enough to edit col1 and col3. When this user press the edit button only the cells in col1 and col3 should display textboxes that allow the user to enter a value. How can this be implemented? I have understood that I should to it in the ItemCreated eventhandler. But I haven't figured out how do it exactly yet. Anyone who can help me? /Rickard

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      RickardB wrote: I have understood that I should to it in the ItemCreated eventhandler No,you should do it in EditItem event handler and set the EditItemIndex of datagrid to e.Item.ItemIndex and then rebind the grid to dataset.Also you should set EditItemTemplate tag in the HTML page of your aspx and set the edit controls that you want to be shown there,then for the problem of privilage,set the Visible attribute for each tag and for the value of it call the function in code-behind which check the permission and return boolean for the proper pemiission. For calling the function from code behind you should do something like this: Visible='< % # functionname(someparameter) % > ' but without any space. Mazy No sig. available now.

      R 1 Reply Last reply
      0
      • M Mazdak

        RickardB wrote: I have understood that I should to it in the ItemCreated eventhandler No,you should do it in EditItem event handler and set the EditItemIndex of datagrid to e.Item.ItemIndex and then rebind the grid to dataset.Also you should set EditItemTemplate tag in the HTML page of your aspx and set the edit controls that you want to be shown there,then for the problem of privilage,set the Visible attribute for each tag and for the value of it call the function in code-behind which check the permission and return boolean for the proper pemiission. For calling the function from code behind you should do something like this: Visible='< % # functionname(someparameter) % > ' but without any space. Mazy No sig. available now.

        R Offline
        R Offline
        RickardB
        wrote on last edited by
        #3

        I am using autogenereted columns so I don't think your suggestion works. The amount and the types of the columns are generated in run time. The autogenerated editcolumns includes a textbox control by default, what I want to do it to set this textbox enabled property to false if the user doesn't has the permissions required to edit data in the specific column. Rickard Berglen, M.Sc.Eng.

        1 Reply Last reply
        0
        • R RickardB

          I am writing a ASP.NET application with a UI based on the DataGrid WebServer Control. The user is able to write back data do the system by clicking on the edit-button in the first column of the datagrid. However, the user is not always allowed to write back data in alls columns, this depends on his/hers priveleges. Example, lets say the datagrid have three columns plus the edit column: edit col1 col2 col3 And the active user only has permissions enough to edit col1 and col3. When this user press the edit button only the cells in col1 and col3 should display textboxes that allow the user to enter a value. How can this be implemented? I have understood that I should to it in the ItemCreated eventhandler. But I haven't figured out how do it exactly yet. Anyone who can help me? /Rickard

          S Offline
          S Offline
          Steve McLenithan
          wrote on last edited by
          #4

          Why not exclude the columns the user should not be editing from the datagrid completely using parameterized sql statements?

          // Steve McLenithan

          Cluelessnes:
             There are no stupid questions, but there are a lot of inquisitive idiots.

          R 1 Reply Last reply
          0
          • S Steve McLenithan

            Why not exclude the columns the user should not be editing from the datagrid completely using parameterized sql statements?

            // Steve McLenithan

            Cluelessnes:
               There are no stupid questions, but there are a lot of inquisitive idiots.

            R Offline
            R Offline
            RickardB
            wrote on last edited by
            #5

            First of all its not connected to a SQL source. The data source is a custom function that constructs the data by reading OPC Historical data from an Industrial Automation System. Second I want the user to be able to see the columns that his not allowed to edit while editing the other columns, to avoid confusion. Anyway, thanks for your reply. Rickard

            S 1 Reply Last reply
            0
            • R RickardB

              First of all its not connected to a SQL source. The data source is a custom function that constructs the data by reading OPC Historical data from an Industrial Automation System. Second I want the user to be able to see the columns that his not allowed to edit while editing the other columns, to avoid confusion. Anyway, thanks for your reply. Rickard

              S Offline
              S Offline
              Steve McLenithan
              wrote on last edited by
              #6

              Ok in that case perhaps you could try setting the fields you want to restrict (textboxes, dropdownmenus,etc) when in edit mode to ReadOnly based on their permission level?

              // Steve McLenithan

              Cluelessnes:
                 There are no stupid questions, but there are a lot of inquisitive idiots.

              R 1 Reply Last reply
              0
              • S Steve McLenithan

                Ok in that case perhaps you could try setting the fields you want to restrict (textboxes, dropdownmenus,etc) when in edit mode to ReadOnly based on their permission level?

                // Steve McLenithan

                Cluelessnes:
                   There are no stupid questions, but there are a lot of inquisitive idiots.

                R Offline
                R Offline
                RickardB
                wrote on last edited by
                #7

                Exactly, this is what I want to do. But how do I do it? Since I don't know the amount of columns in the datagrid until it is generated in design time my idea is to somehow modify the text boxes that appear when your press the "update" button in the ItemCreated Event handler. But for some reason I can't get hold of those textboxes. Rickard

                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