On 7 Jun 2006 08:10:35 -0700, "Raja" <> wrote:
>Hi Everybody
>Just playing with ObjectDataSource and noticed the following.
>I have a Gridview which binds to a ObjectDataSource. ObjectDataSource
>gets data from a typed dataset created with VWD. In the table from
>which the data is coming has a Primary Key field.
>
>Gridview is set to edit mode. DataKeyNames = "PK_Field". Now if PK
>field is not readonly, then data is updated successfully. But if I set
>PK Field to readonly, then data is not updated. During the debugging I
>see that e.InputParameters does not return any value for readonly PK
>field. Probably no textbox created for readonly field, so no value.
>
>How can I have the Gridview to update a record with readonly Primary
>Key field?
>Offcourse, there are many other ways to update, but I do not believe
>that if I turn my PK field to readonly, then I have to change a lot of
>code.
>I must be missing something.
I think you are missing something. The ODS I published on MSDN for
use with membership
http://msdn.microsoft.com/library/de...memroleman.asp
has it's prmiary key as Username. You need to set the
DataObjectField's first attribute to true and I think you will be OK.
In my code I actually have UserName set to readonly in my primary
gridview so I know it works.
Good luck
/// <summary>
/// This calls the base class UserName property. It is here
so we can tag
/// this property as the primary key so that datakeynames
attribute gets set in the data control.
/// </summary>
///
[DataObjectField(true,false,false)]
public override string UserName
{
get { return base.UserName; }
}
Peter Kellner
http://peterkellner.net