Disabling a datagrid edit column

Results 1 to 3 of 3

Thread: Disabling a datagrid edit column

  1. #1
    Join Date
    Dec 1969

    Default Disabling a datagrid edit column

    Is there a way to disable the datagrid edit? When my page is being loaded a security object checks the users rights. If they have read only rights then I need to disable the edit/update columns of the datagrid. They still need to be able to use the grid, page through the records etc, just not the edit/update commands.<BR><BR>Thanks for the help.

  2. #2
    Join Date
    Dec 1969

    Default sure

    If securityObj.Readonly = True then<BR> datagridName.Columns(7).Visible = False<BR>End If<BR><BR>where securityObj.Readonly is your user rights look up<BR><BR>and I am assuming the &#060;asp:EditCommandColumn is number 7 in your datagrid....<BR><BR>BTW - find a way to do this by column name rather than number I would be very interested to hear it. I prefer not have things like this tightly coupled<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: sure

    I&#039;m using the "ItemDataBound" event.. i&#039;ll comment the direct code so it makes the most sense<BR><BR> Public Sub ShowThreads_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)<BR> Dim item As DataGridItem = e.Item<BR> If item.ItemIndex &#062; -1 Then &#039;Protects against looking at the header or footer<BR> If Not (GetThisUserID() = Clng0(item.Cells(2).Text)) Then &#039;GetThisUserID is my function to get logged in #, Cell(2) is a hidden column with the ID of who posted it<BR> Dim editButton As LinkButton<BR> editButton = item.Cells(0).Controls(0)<BR> If CBool(InStr(editButton.Text, "Edit This Message")) Then &#039;This is kind a cheezy way, but i look at the edit text<BR> editButton.Text = "&nbsp;" <BR> editButton.Enabled = False &#039;Disable it if ID&#039;s don&#039;t match<BR> End If<BR> End If<BR> End If<BR> End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts