GridView - how to make a cell uneditable?

Discussion in 'ASP .Net' started by Steve Kershaw, Sep 19, 2007.

  1. Hi,

    I have a gridview with an UpdateQuery() that's fired when the user
    edits/updates a row. The problem lies in the fact that every cell in
    the edited row shows up as editable even though one cell actually gets
    changed in the database.

    Is there a way to make a cell appear non-editable?

    Thanks
     
    Steve Kershaw, Sep 19, 2007
    #1
    1. Advertising

  2. Steve Kershaw

    Sergio E. Guest

    set inertvisible=false
    "Steve Kershaw" <> escribió en el mensaje
    news:...
    > Hi,
    >
    > I have a gridview with an UpdateQuery() that's fired when the user
    > edits/updates a row. The problem lies in the fact that every cell in
    > the edited row shows up as editable even though one cell actually gets
    > changed in the database.
    >
    > Is there a way to make a cell appear non-editable?
    >
    > Thanks
    >
     
    Sergio E., Sep 19, 2007
    #2
    1. Advertising

  3. Steve Kershaw

    David Wier Guest

    From the Gridview's smart tag, go in and edit the cells - for each column
    you do not want editable, make it's property ReadONLY

    --

    David Wier
    http://aspnet101.com
    http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
    bloated markup


    "Steve Kershaw" <> wrote in message
    news:...
    > Hi,
    >
    > I have a gridview with an UpdateQuery() that's fired when the user
    > edits/updates a row. The problem lies in the fact that every cell in
    > the edited row shows up as editable even though one cell actually gets
    > changed in the database.
    >
    > Is there a way to make a cell appear non-editable?
    >
    > Thanks
    >
     
    David Wier, Sep 19, 2007
    #3
  4. Steve Kershaw

    Monty Guest

    If you want more ganular control:

    Private Sub grid_RowDataBound(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
    Handles grdLineItems.RowDataBound

    If e.Row.RowType = DataControlRowType.DataRow Then
    If (e.Row.RowState = DataControlRowState.Edit) Or _
    (e.Row.RowState = DataControlRowState.Alternate + _
    DataControlRowState.Edit) Then
    Dim oTxt As TextBox = e.Row.FindControl("txtFoo")
    If oTxt IsNot Nothing Then oTxt.Enabled = False
    End If
    End If
    End Sub


    "Steve Kershaw" <> wrote in message
    news:...
    > Hi,
    >
    > I have a gridview with an UpdateQuery() that's fired when the user
    > edits/updates a row. The problem lies in the fact that every cell in
    > the edited row shows up as editable even though one cell actually gets
    > changed in the database.
    >
    > Is there a way to make a cell appear non-editable?
    >
    > Thanks
    >
     
    Monty, Sep 19, 2007
    #4
  5. On Sep 19, 2:02 pm, "Monty" <> wrote:
    > If you want more ganular control:
    >
    > Private Sub grid_RowDataBound(ByVal sender As Object, _
    > ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
    > Handles grdLineItems.RowDataBound
    >
    > If e.Row.RowType = DataControlRowType.DataRow Then
    > If (e.Row.RowState = DataControlRowState.Edit) Or _
    > (e.Row.RowState = DataControlRowState.Alternate + _
    > DataControlRowState.Edit) Then
    > Dim oTxt As TextBox = e.Row.FindControl("txtFoo")
    > If oTxt IsNot Nothing Then oTxt.Enabled = False
    > End If
    > End If
    > End Sub
    >
    > "Steve Kershaw" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi,

    >
    > > I have a gridview with an UpdateQuery() that's fired when the user
    > > edits/updates a row. The problem lies in the fact that every cell in
    > > the edited row shows up as editable even though one cell actually gets
    > > changed in the database.

    >
    > > Is there a way to make a cell appear non-editable?

    >
    > > Thanks- Hide quoted text -

    >
    > - Show quoted text -


    I tried setting the un-editable columns to ReadOnly="true" but when I
    actually update through the ObjectDataSource the editable column isn't
    updated. It's acting like it dosen't see the data in the
    ReadOnly="true" columns. For example:

    UPDATE myTable
    SET myEdit = :myEdit
    WHERE myNonEdit = :myNonEdit (doesn't see myNonEdit because of the
    ReadOnly="true")
    AND...

    Note the ":" instead of the "@" because this is an Oracle (not SQL
    Server) database.

    Thanks so much for your help!
    Steve
     
    Steve Kershaw, Sep 20, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    530
  2. Deshaies
    Replies:
    3
    Views:
    4,554
    Deshaies
    Apr 20, 2004
  3. Ike

    Textarea UnEditable

    Ike, Dec 17, 2003, in forum: HTML
    Replies:
    4
    Views:
    19,742
    sinrize
    Jul 23, 2007
  4. Mike P
    Replies:
    3
    Views:
    4,218
    PeterKellner
    Jun 6, 2006
  5. Replies:
    6
    Views:
    629
    Nigel Wade
    Sep 3, 2012
Loading...

Share This Page