Nested DDL in GridView ItemTemplates

  • Thread starter Thread starter bigbrorpi
  • Start date Start date
B

bigbrorpi

Hi

I have a FormView that contains a GridView. The GridView is populated
from an ObjectDataSource. Two of the columns in the GridView are not
bound, and the values used in Update mode come from dropdowns (inside
of ItemTemplates).

In my ObjectDataSource, I have Parameters for the bound fields, and
ControlParameters for the DDLs. I cannot seem to access the DDLs since
they are so nested. I've tried:
<asp:ControlParameter ControlID="FormView$GridView$DDL" ......[Snipped]
but that doesn't work.
I've tried to do a GridView.FindControl with the ID of the DDL, but it
doesn't find it.
My GridView looks like this:

<asp:GridView id="CommGridView" runat="server"
DataKeyNames="id" DataSourceID="ObjectDataSource5"
AutoGenerateColumns="false" AutoGenerateEditButton=true>
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:DropDownList ID="DropDownListCommFields"
runat="server" DataSourceID="SqlDataSourceCommFields"
DataValueField="id" DataTextField="field" />
</EditItemTemplate>
<HeaderTemplate>
<b>Field</b>
</HeaderTemplate>
<ItemTemplate>
<%#CommFldLkp(Eval("field"))%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
.......[Snipped]

Does anyone know how I can access the values stored in the DDL for use
as ControlParameters?

Thanks
 
You need to put the ObjectDataSource control within the TemplateField which
contains the DDLs.
 
OK Thanks. Since I have multiple template fields, do I just put it in
the first template field?

Thanks
 
Back
Top