469,904 Members | 2,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

Nested DDL in GridView ItemTemplates

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

Apr 5 '06 #1
2 2241
You need to put the ObjectDataSource control within the TemplateField which
contains the DDLs.

"bi*******@gmail.com" wrote:
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

Apr 5 '06 #2
OK Thanks. Since I have multiple template fields, do I just put it in
the first template field?

Thanks

Apr 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by hammad.awan_nospam | last post: by
reply views Thread by sloan | last post: by
4 posts views Thread by Congero | last post: by
1 post views Thread by ram_kri | last post: by
reply views Thread by Sody | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.