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

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

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

    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 Guest

  2. Similar Questions and Discussions

    1. how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column
      i am trying to trap the value of one dropdownlist (in a datagrid edititemtemplate column) at the time its selectedindexchanged event fires and use...
    2. Changing an image in a datagrid column in the ItemDataBound event
      Hi, I have a datagrid that is bound to a datatable, I'm using TemplateColumns. The heading of two columns of the datagrid fire the...
    3. AutoGenerateColumns, UpdateCommand, Column Width
      How can I customize the width of the text boxes / columns of my DataGrid, in Edit Mode (UpdateCommand event), when using AutoGenerateColumns? ...
    4. Click event on ImageButton column in a datagrid
      Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I...
    5. getting column value in ItemCreated datagrid event
      got it. use DataItem("columnname"( "Learning SQL Server" <no.mail.com> wrote in message news:ulsj5VNYDHA.4040@tk2msftngp13.phx.gbl......
  3. #2

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

    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:OO1KZBOXDHA.1888@TK2MSFTNGP10.phx.gbl...
    > 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:Om0ZfkNXDHA.2392@TK2MSFTNGP10.phx.gbl...
    > > 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 Guest

  4. #3

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

    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" <bob2.johnson@ncmail.net> wrote in message
    news:eJdBPMOXDHA.608@TK2MSFTNGP12.phx.gbl...
    > 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:OO1KZBOXDHA.1888@TK2MSFTNGP10.phx.gbl...
    > > 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:Om0ZfkNXDHA.2392@TK2MSFTNGP10.phx.gbl...
    > > > 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 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139