REPOST: Column [blah] is readonly on Datagrid UpdateCommand event

Discussion in 'ASP .Net' started by Learning SQL Server, Aug 7, 2003.

  1. Forgive the repost, but this is really troublesome and I hope SOMEONE can
    shed some light on it.

    I am trying to update a datarow via in-place editing from a dataset stored
    in session.

    When I try to write the new value into the selected row, I always get the
    following error : Column [blah] is read-only.

    in my UpdateCommand event I have:

    ' obtain the dataset saved in session on first page load.
    dim objDS as DataSet = Ctype(Session("foo"), DataSet)

    ' then select the row I want to update from the first table in the
    collection,
    ' using the text in the second cell as the criteria.
    If IsNothing(objDS) = false then
    dim objDT as DataTable = objDS.Tables(0)
    dim objRow as DataRow = objDT.Select("Type=" +
    e.Item.Cells(1).Text.ToString)

    ' TERMINATES ON THIS LINE:
    objRow(0)("Column1") = CType(e.Item.Cells(2).Controls(0), TextBox).Text
    ...
    End If

    When I check the Immediate window to find out what the state of my dataset
    is, all the columns have the following attribute set:
    Readonly = true

    And I have no idea why this is. Is it because the dataset is being pulled
    from a session variable???

    I am following the example provided in Dino Esposito's text Building Web
    Solutions with ASP.NET and ADO.NET. This doesnt work though. Why?
     
    Learning SQL Server, Aug 7, 2003
    #1
    1. Advertising

  2. Learning SQL Server

    Bob Johnson Guest

    Almost every field in the dataset model that would actually be useful is
    Read Only. Thats my biggest complaint with the stupid thing.


    "Learning SQL Server" <no.mail.com> wrote in message
    news:...
    > Solved. Hooray for me. Maybe someone can clarify this:
    > I stumbled across a posting elsewhere that recommended looping through

    each
    > column and setting the ReadOnly attribute to "False". And this caused the
    > update to occur properly. The column is not a key, and its not a view (it

    is
    > a table), so why would these start as Readonly to begin with???
    >
    >
    >
    > "Learning SQL Server" <no.mail.com> wrote in message
    > news:...
    > > Forgive the repost, but this is really troublesome and I hope SOMEONE

    can
    > > shed some light on it.
    > >
    > > I am trying to update a datarow via in-place editing from a dataset

    stored
    > > in session.
    > >
    > > When I try to write the new value into the selected row, I always get

    the
    > > following error : Column [blah] is read-only.
    > >
    > > in my UpdateCommand event I have:
    > >
    > > ' obtain the dataset saved in session on first page load.
    > > dim objDS as DataSet = Ctype(Session("foo"), DataSet)
    > >
    > > ' then select the row I want to update from the first table in the
    > > collection,
    > > ' using the text in the second cell as the criteria.
    > > If IsNothing(objDS) = false then
    > > dim objDT as DataTable = objDS.Tables(0)
    > > dim objRow as DataRow = objDT.Select("Type=" +
    > > e.Item.Cells(1).Text.ToString)
    > >
    > > ' TERMINATES ON THIS LINE:
    > > objRow(0)("Column1") = CType(e.Item.Cells(2).Controls(0),

    > TextBox).Text
    > > ...
    > > End If
    > >
    > > When I check the Immediate window to find out what the state of my

    dataset
    > > is, all the columns have the following attribute set:
    > > Readonly = true
    > >
    > > And I have no idea why this is. Is it because the dataset is being

    pulled
    > > from a session variable???
    > >
    > > I am following the example provided in Dino Esposito's text Building Web
    > > Solutions with ASP.NET and ADO.NET. This doesnt work though. Why?
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Bob Johnson, Aug 7, 2003
    #2
    1. Advertising

  3. Bob:

    Thanks for the reply.

    That IS silly. Additionally, I see very little in (at least my)
    books/documentation that discusses the Readonly attribute being the default
    state for the DataColumn object in a DataTable (it is NOT discussed in the
    example of this book I am reading).



    "Bob Johnson" <> wrote in message
    news:...
    > Almost every field in the dataset model that would actually be useful is
    > Read Only. Thats my biggest complaint with the stupid thing.
    >
    >
    > "Learning SQL Server" <no.mail.com> wrote in message
    > news:...
    > > Solved. Hooray for me. Maybe someone can clarify this:
    > > I stumbled across a posting elsewhere that recommended looping through

    > each
    > > column and setting the ReadOnly attribute to "False". And this caused

    the
    > > update to occur properly. The column is not a key, and its not a view

    (it
    > is
    > > a table), so why would these start as Readonly to begin with???
    > >
    > >
    > >
    > > "Learning SQL Server" <no.mail.com> wrote in message
    > > news:...
    > > > Forgive the repost, but this is really troublesome and I hope SOMEONE

    > can
    > > > shed some light on it.
    > > >
    > > > I am trying to update a datarow via in-place editing from a dataset

    > stored
    > > > in session.
    > > >
    > > > When I try to write the new value into the selected row, I always get

    > the
    > > > following error : Column [blah] is read-only.
    > > >
    > > > in my UpdateCommand event I have:
    > > >
    > > > ' obtain the dataset saved in session on first page load.
    > > > dim objDS as DataSet = Ctype(Session("foo"), DataSet)
    > > >
    > > > ' then select the row I want to update from the first table in the
    > > > collection,
    > > > ' using the text in the second cell as the criteria.
    > > > If IsNothing(objDS) = false then
    > > > dim objDT as DataTable = objDS.Tables(0)
    > > > dim objRow as DataRow = objDT.Select("Type=" +
    > > > e.Item.Cells(1).Text.ToString)
    > > >
    > > > ' TERMINATES ON THIS LINE:
    > > > objRow(0)("Column1") = CType(e.Item.Cells(2).Controls(0),

    > > TextBox).Text
    > > > ...
    > > > End If
    > > >
    > > > When I check the Immediate window to find out what the state of my

    > dataset
    > > > is, all the columns have the following attribute set:
    > > > Readonly = true
    > > >
    > > > And I have no idea why this is. Is it because the dataset is being

    > pulled
    > > > from a session variable???
    > > >
    > > > I am following the example provided in Dino Esposito's text Building

    Web
    > > > Solutions with ASP.NET and ADO.NET. This doesnt work though. Why?
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Learning SQL Server, Aug 7, 2003
    #3
    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. evolve
    Replies:
    2
    Views:
    509
    William Ryan
    Nov 2, 2003
  2. A. Kong
    Replies:
    2
    Views:
    4,840
    Iwo Mergler
    Oct 11, 2004
  3. Hylander
    Replies:
    0
    Views:
    425
    Hylander
    Jan 16, 2004
  4. yaru22
    Replies:
    25
    Views:
    721
    Daniel Dyer
    Jan 8, 2007
  5. Jonathan Hyatt
    Replies:
    1
    Views:
    2,135
    Jonathan Hyatt
    Jun 8, 2004
Loading...

Share This Page