GridView with ObjectDataSource
am 11.01.2008 14:27:42 von Andrew Jones
If there is a better place to post this please let me know.
I have a GridView whose Data is bound to an ObjectDataSource ( BLL - DAL ).
When I click Edit on a Row in that GridView I want one of my edit template
fields to fill a DropDownList based on a value from another column on that
same row.
That DropDownList is bound to a different ObjectDataSource that is within
that EditTemplate.
I am using the Selecting Event on that ObjectDataSource to set up the
parameter so the datasource populated according, but I don't know where to
get that value from the GridView Row that is being edited. There is an
EditIndex on the GridView that represents the row I am editing, but the
GridView at the time of this event is not populated and this particular
Gridview has sorting enabled so I can't rely on the natural order of the
datasource.
Any Ideas?
-AJ
RE: GridView with ObjectDataSource
am 14.01.2008 19:30:00 von chad
have you tried using a ControlParameter within your drop down's
ObjectDataSource control pointing to another control in the EditItemTemplate
that the drop down list is in? I have in the past added a HiddenField control
to the same EditItemTemplate so that the NamingContainer will allow the
ObjectDataSource, upon binding, to grab that value property as a parameter
when selecting. For some reason this magically works when perfoming complex
databinding such as this but I can never seem to recreate the behavior in the
code-behind myself.
--
Chad Scharf
_______________________________
http://www.chadscharf.com
"Andrew Jones" wrote:
> If there is a better place to post this please let me know.
>
> I have a GridView whose Data is bound to an ObjectDataSource ( BLL - DAL ).
> When I click Edit on a Row in that GridView I want one of my edit template
> fields to fill a DropDownList based on a value from another column on that
> same row.
> That DropDownList is bound to a different ObjectDataSource that is within
> that EditTemplate.
>
> I am using the Selecting Event on that ObjectDataSource to set up the
> parameter so the datasource populated according, but I don't know where to
> get that value from the GridView Row that is being edited. There is an
> EditIndex on the GridView that represents the row I am editing, but the
> GridView at the time of this event is not populated and this particular
> Gridview has sorting enabled so I can't rely on the natural order of the
> datasource.
>
> Any Ideas?
>
> -AJ
>
>
>
>