469,282 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

GridView could not find control 'xxx' in controlparameter 'xxx'

I have a checkbox control in a GridView EditItemTemplate. My SqlDataAdapter
complains when I try and use UpdateCommand

Thanks on any binding clarification.

GridView:
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Eval("Active") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Bind("Active") %>' />
</EditItemTemplate>
</asp:TemplateField>
UpdateCommand="Update dbo.Vans set VendorVanNo=@VendorVanNo, ...
Active=@Active ... where VanId=@VanId">
<UpdateParameters>
<asp:Parameter Name="VendorVanNo"/>
...
<asp:ControlParameter Name="ActiveCheckBox"
ControlId="ActiveCheckbox" PropertyName="Checked"/>
...
</UpdateParameters>

Mar 22 '06 #1
3 16822
The way that databinding on the GridView works is that the ASP.NET passes an
IorderedDictionary containing the controls values extracted from the Bind
expression.

The updateparameters should not be referring to controls within the
templates because the checkbox “ActiveCheckbox” is not visible as indepdent
control, it only exists within the EditItemTemplate of the GridView. All you
needed to do within the updateparameters collection is list the fieldnames
(the same the ones you used in the Bind expressions) that have been databound
or that are DataKeys on the GridView, e.g.,

<UpdateParameters>
<asp:Parameter Name="VendorVanNo" Type="Int32"/>
<asp:Parameter Name="Active" Type="Boolean"/>
</UpdateParameters>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I have a checkbox control in a GridView EditItemTemplate. My SqlDataAdapter
complains when I try and use UpdateCommand

Thanks on any binding clarification.

GridView:
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Eval("Active") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Bind("Active") %>' />
</EditItemTemplate>
</asp:TemplateField>
UpdateCommand="Update dbo.Vans set VendorVanNo=@VendorVanNo, ...
Active=@Active ... where VanId=@VanId">
<UpdateParameters>
<asp:Parameter Name="VendorVanNo"/>
...
<asp:ControlParameter Name="ActiveCheckBox"
ControlId="ActiveCheckbox" PropertyName="Checked"/>
...
</UpdateParameters>

Mar 23 '06 #2

Aha, the fog is clearing! and the UpdateParameter uses the C# datatype, not
the SQL datatype as in boolean vs bit.

Thanks Phillip

"Phillip Williams" wrote:
The way that databinding on the GridView works is that the ASP.NET passes an
IorderedDictionary containing the controls values extracted from the Bind
expression.

The updateparameters should not be referring to controls within the
templates because the checkbox “ActiveCheckbox” is not visible as indepdent
control, it only exists within the EditItemTemplate of the GridView. All you
needed to do within the updateparameters collection is list the fieldnames
(the same the ones you used in the Bind expressions) that have been databound
or that are DataKeys on the GridView, e.g.,

<UpdateParameters>
<asp:Parameter Name="VendorVanNo" Type="Int32"/>
<asp:Parameter Name="Active" Type="Boolean"/>
</UpdateParameters>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I have a checkbox control in a GridView EditItemTemplate. My SqlDataAdapter
complains when I try and use UpdateCommand

Thanks on any binding clarification.

GridView:
<asp:TemplateField HeaderText="Active">
<ItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Eval("Active") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="ActiveCheckBox" runat="server" Checked='<%#
Bind("Active") %>' />
</EditItemTemplate>
</asp:TemplateField>
UpdateCommand="Update dbo.Vans set VendorVanNo=@VendorVanNo, ...
Active=@Active ... where VanId=@VanId">
<UpdateParameters>
<asp:Parameter Name="VendorVanNo"/>
...
<asp:ControlParameter Name="ActiveCheckBox"
ControlId="ActiveCheckbox" PropertyName="Checked"/>
...
</UpdateParameters>

Mar 23 '06 #3
Thanks for the tip! I was trying to use a ControlParameter

Apr 2 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Lee Moore | last post: by
4 posts views Thread by Bishop | last post: by
3 posts views Thread by Mike P | last post: by
5 posts views Thread by mosscliffe | last post: by
1 post views Thread by kashif456 | last post: by
4 posts views Thread by =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.