|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ObjectDataSource .net 2.0I'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 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. Show quoteHide quote "Joe Reiss" <joere***@bellsouth.net> wrote in message news:C7mkf.44123$s92.8533@bignews6.bellsouth.net... > 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 >
VS2005 is a PIECE of Garbage and is bug Ridden
drop down list box - client side code won't execute OnSelectedIndexChange validation summary not always showing message box DataGrid and ViewState Display an images in Datagrid uniqueidentifier and updating record client side access. Lost with User Controls Why usercontrol won't allow Request.Cookies Pls help me |
|||||||||||||||||||||||