ObjectDataSource .net 2.0

J

Joe Reiss

Hi all,

I'm using a gridview with a embedded dropdownlist and a objectDatasource as
its DataSource. The objectDatasource uses a DataObjectType for its data
instead of the parameter collections for Select,Update,Insert and Delete
methods.

In this Gridview I have a dropDownList which displays a value from another
table via a Foreign Key. So far so good. When the user changes this value
I need to update the FK, so, in the grid's RowUpdating event is where I
would update the FK, correct? So, what I need to know is how to update this
value which is in the underlying dataset of the objectDataSourrce. The
psuedo code below is where I'm stuck:

(ddlRole.Items[ddlRole.SelectedIndex].Value) represents my new value from
the dropdownlist. Now I need to assign this to the datasource represented
by the objectDatasource? If this is the correct strategy, then how do I get
at the current row of data that's in the objectDatasource, something like
the code below: RoleID is my FK. ddlRole is my embedded dropdown in my
gridview.

MyObjectDataSource.CurrentRow.RoleID.Value =
ddlRole.Items[ddlRole.SelectedIndex].Value;

Thanx,
Joe
 
A

Andrew Robinson

Joe,

Don't know if you have found a solution to this yet, but I was looking my
self. I couldn't find anything but figured it out so I thought I would post
the answer. Please let me know if this works for you via one of the links
below.

Basically, if you use a Bind instead of the Eval, the system will handle
your updating correctly for you.

<asp:DropDownList ID="DropDownListRegion" runat="server" DataSource='<%#
GetSchoolRegions() %>'

DataTextField="SchoolRegionName" DataValueField="SchoolRegionID"

SelectedValue='<%# Bind("SchoolRegionID") %>' />



Hope t his helps....

Also, the way that you are working at it, you can use
DropDownListRoll.SelectedValue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top