473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SqlDataSource ControlParameter from DetailsView dropdownlist

K B
Hi,

I've tried this several ways but get the error that the control can't be
found.

I have a details view with a dropdownlist in the EditItemTemplate
populated and assigned the selected value in code.

I need to get the selected value when the record is saved. I've tried
using the following in the SqlDataSource updating event:

Dim sWF As String = (CType(dvAddProcess.FindControl("ddlWfEdit"),
DropDownList)).SelectedValue
e.Command.Parameters("@WorkFlowDoc").Value = sWF

I've also tried adding a ControlParameter to the SqlDataSource Update
parameters list:

<asp:ControlParameter ControlID="dvAddProcess$ddlWfEdit" Type="string"
Name="WorkFlowDoc" PropertyName="SelectedValue" />

Could anyone tell me where I'm going wrong?

thanks,
KB
*** Sent via Developersdex http://www.developersdex.com ***
Jul 16 '06 #1
3 9849
Hello K,

The problem most likely is that the FindControl doesn't do a good job of
going down a hierarchy until it finds the control. I use this little utility
function to find FormView controls (sorry for the C#, but hopefully you can
convert it):

public static Control FindControl(Control parent, string id)
{
if (parent != null && parent.Controls != null && parent.Controls.Count
!= 0)
{

Control ctrl = parent.FindControl(id);
if (ctrl != null)
{
return ctrl;
}
else
{
foreach (Control subCtrl in parent.Controls)
{
ctrl = FindControl(subCtrl, id);
if (ctrl != null) return ctrl;
}
}
}

return null;
}
Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
Hi,

I've tried this several ways but get the error that the control can't
be found.

I have a details view with a dropdownlist in the EditItemTemplate
populated and assigned the selected value in code.

I need to get the selected value when the record is saved. I've tried
using the following in the SqlDataSource updating event:

Dim sWF As String = (CType(dvAddProcess.FindControl("ddlWfEdit"),
DropDownList)).SelectedValue
e.Command.Parameters("@WorkFlowDoc").Value = sWF

I've also tried adding a ControlParameter to the SqlDataSource Update
parameters list:

<asp:ControlParameter ControlID="dvAddProcess$ddlWfEdit" Type="string"
Name="WorkFlowDoc" PropertyName="SelectedValue" />

Could anyone tell me where I'm going wrong?

thanks,
KB
*** Sent via Developersdex http://www.developersdex.com ***

Jul 16 '06 #2
K B
Shawn,

It's a little over my head to see where I apply this. Any ideas why I
can't use the ControlParemeter because that way I can specify the
control name AND the parent control? But it isn't found.

<asp:ControlParameter ControlID="dvAddProcess$ddlWfInsert" Type="string"
Name="WorkFlowDoc" PropertyName="SelectedValue" />

Thanks for responding!

K

*** Sent via Developersdex http://www.developersdex.com ***
Jul 16 '06 #3
Hello K,

As far as I know, this doesn't work because it can't parse the dvAddProcess$ddlWfInsert
to figure out what you mean is the ddlWfInsert control inside the DetailsView.
So you need to do it on the DataSource's Selecting event.
Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
Shawn,

It's a little over my head to see where I apply this. Any ideas why I
can't use the ControlParemeter because that way I can specify the
control name AND the parent control? But it isn't found.

<asp:ControlParameter ControlID="dvAddProcess$ddlWfInsert"
Type="string" Name="WorkFlowDoc" PropertyName="SelectedValue" />

Thanks for responding!

K

*** Sent via Developersdex http://www.developersdex.com ***

Jul 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stu | last post by:
I have a GridView that pulls straight from a table. This uses SqlDataSource1. SqlDataSource2 grabs data from the same table, but only 1 row to fill a DeatilsView, this SqlDataSource2 uses a...
2
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them...
3
by: simonZ | last post by:
In gridView I have dropdown list : <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField...
2
by: Dabbler | last post by:
I have a TextBox used to enter a search value and a DropDownList used to select which field should be searched on. I need to load a GridView with the search results. I have setup multiple select...
2
by: Dabbler | last post by:
I'm trying to load a DropDownList in a Gridview from a secondary SqlDataSource but I get an exception complaining that the ControlParameter's ControlId isn't found. "Could not find control...
0
by: jobs | last post by:
I have a gridview that times when selecting from specific table when I try to when I add a where clause. Even when I'm only seleting Top 1 which comes right back at the command line. I test the...
1
by: David Lozzi | last post by:
Howdy, ASP.Net 2.0 using VB on SQL 2005 This is a two fold issue. I have a DetailsView control which users can insert or edit items. Editing works great. Insert works great however I need...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
0
by: staeri | last post by:
I have a dropdownlist attached to a SqlDataSource inside an Accordion. I receive the following error message when the SqlDataSource is inside the Accordion: "The DataSourceID of 'ddGroup' must...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.