The way around that, that I am using, is converting the
column to a
template column and then in the gridview_updating event set
the value
to your object property.
My object has the following structure:
The StoreGroup object contains a HoldingCompany object which
exposes two
properties, an ID and a Name:
StoreGroup.HoldingCompany.HoldingCompany_ID
StoreGroup.HoldingCompany.HoldingCompanyName
If you want to display the HoldingCompanyName in your
gridview you
first convert the column to a template column as follows:
<asp:TemplateField HeaderText="Holding
Company">
<ItemTemplate>
<asp:Label ID="Label1"
runat="server" Text='<%# Eval
("HoldingCompany.HoldingCompanyName") %>'
Width="300px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="StoreGroupTextBox"
runat="server" Text='<%# Eval
("HoldingCompany.HoldingCompanyName") %>'
Width="300px">
</EditItemTemplate>
</asp:TemplateField>
and then in the code behind:
(
assuming my ObjectDataSource is called
StoreGroupObjectDataSource
and your gridview is called gvwStoreGroup
)
protected void
StoreGroupObjectDataSource_Updating(object sender,
ObjectDataSourceMethodEventArgs e)
{
StoreGroup myStoreGroup =
(StoreGroup)e.InputParameters[0];
TextBox myTempTextBox =
((TextBox)this.gvwStoreGroup.Rows
[this.gvwStoreGroup.EditIndex].FindControl("StoreGroup
TextBox"));
myStoreGroup.HoldingCompany.HoldingCompanyName =
Server.HtmlEncode
(myTempTextBox.Text);
}
This method is much more cumbersome that simply doing a Bind
("HoldingCompany.HoldingCompanyName")
but it is the only way around I found.
I hope this helps.
Regards,
Yago Alvarado
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|