ObjectDataSource and GridView

Discussion in 'ASP .Net' started by Just Me, Mar 21, 2008.

  1. Just Me

    Just Me Guest

    Hi,

    I am using the gridview with a business object ( just a function which
    updates using a stored proc on sqo2005 ). Anyway.

    Basically, the reord displayed in the grid is simple

    ExpenseWeekID WeekEndingDate AmountPaid.


    OK, now, when I click the edit link on the gridview, it puts the grid into
    edit mode. ( Note that the ExpenseWeekID is listed as readonly as its the
    primary key.

    I Make my update to lets say the amountpaid and click Update. This caused
    my update function to be called and the parameters are passed to the
    function. these are the three already listed.

    ExpenseWeekID WeekEndingDate AmountPaid.

    However, the EspenseWeekID, is of course read only and the value passes is
    allways ( 0 ) meaning that the update cannot work. If I then change this
    from read only so that when the grid is in edit mode, and then click update
    the correct value is passed to my functiona and the update workds properly.

    HOWEVER, I dont want the Primarykey to be in editable mode, how can I
    overcome this without having to code all this manually.

    Cheers
    Just Me, Mar 21, 2008
    #1
    1. Advertising

  2. Just Me

    Just Me Guest

    Actually, I think ive found the answer.

    One needs to use DataKeyNames="myKey" to tell the gridview what the key is
    for the displayed records. However, this should have been automatic, I
    assume it was the order in which I built the components on the page. I
    guess, I should have defined the datasource before I created the gridview
    ????




    "Just Me" <news.microsoft.com> wrote in message
    news:e%...
    > Hi,
    >
    > I am using the gridview with a business object ( just a function which
    > updates using a stored proc on sqo2005 ). Anyway.
    >
    > Basically, the reord displayed in the grid is simple
    >
    > ExpenseWeekID WeekEndingDate AmountPaid.
    >
    >
    > OK, now, when I click the edit link on the gridview, it puts the grid into
    > edit mode. ( Note that the ExpenseWeekID is listed as readonly as its the
    > primary key.
    >
    > I Make my update to lets say the amountpaid and click Update. This caused
    > my update function to be called and the parameters are passed to the
    > function. these are the three already listed.
    >
    > ExpenseWeekID WeekEndingDate AmountPaid.
    >
    > However, the EspenseWeekID, is of course read only and the value passes is
    > allways ( 0 ) meaning that the update cannot work. If I then change this
    > from read only so that when the grid is in edit mode, and then click
    > update the correct value is passed to my functiona and the update workds
    > properly.
    >
    > HOWEVER, I dont want the Primarykey to be in editable mode, how can I
    > overcome this without having to code all this manually.
    >
    > Cheers
    >
    Just Me, Mar 21, 2008
    #2
    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. Eiriken

    ObjectDataSource and GridView

    Eiriken, Jan 19, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,774
    Eiriken
    Jan 19, 2006
  2. J055
    Replies:
    10
    Views:
    10,666
    chris22smith
    Mar 18, 2009
  3. Replies:
    1
    Views:
    3,451
    Brock Allen
    May 3, 2006
  4. Olivier Matrot
    Replies:
    2
    Views:
    3,296
    Walter Wang [MSFT]
    Oct 2, 2006
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    238
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page