Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

GridView - how to make a cell uneditable?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Kershaw - 19 Sep 2007 16:26 GMT
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. - 19 Sep 2007 16:46 GMT
set inertvisible=false
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks
David Wier - 19 Sep 2007 16:50 GMT
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

Signature

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

> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks
Monty - 19 Sep 2007 21:02 GMT
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

> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks
Steve Kershaw - 20 Sep 2007 21:23 GMT
> If you want more ganular control:
>
[quoted text clipped - 24 lines]
>
> - 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.