473,739 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlDataSource ControlParamete r 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 EditItemTemplat e
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(dvAddPro cess.FindContro l("ddlWfEdit" ),
DropDownList)). SelectedValue
e.Command.Param eters("@WorkFlo wDoc").Value = sWF

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

<asp:ControlPar ameter ControlID="dvAd dProcess$ddlWfE dit" Type="string"
Name="WorkFlowD oc" PropertyName="S electedValue" />

Could anyone tell me where I'm going wrong?

thanks,
KB
*** Sent via Developersdex http://www.developersdex.com ***
Jul 16 '06 #1
3 9868
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(Con trol parent, string id)
{
if (parent != null && parent.Controls != null && parent.Controls .Count
!= 0)
{

Control ctrl = parent.FindCont rol(id);
if (ctrl != null)
{
return ctrl;
}
else
{
foreach (Control subCtrl in parent.Controls )
{
ctrl = FindControl(sub Ctrl, 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 EditItemTemplat e
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(dvAddPro cess.FindContro l("ddlWfEdit" ),
DropDownList)). SelectedValue
e.Command.Param eters("@WorkFlo wDoc").Value = sWF

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

<asp:ControlPar ameter ControlID="dvAd dProcess$ddlWfE dit" Type="string"
Name="WorkFlowD oc" PropertyName="S electedValue" />

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 ControlParemete r because that way I can specify the
control name AND the parent control? But it isn't found.

<asp:ControlPar ameter ControlID="dvAd dProcess$ddlWfI nsert" Type="string"
Name="WorkFlowD oc" PropertyName="S electedValue" />

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$dd lWfInsert
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 ControlParemete r because that way I can specify the
control name AND the parent control? But it isn't found.

<asp:ControlPar ameter ControlID="dvAd dProcess$ddlWfI nsert"
Type="string" Name="WorkFlowD oc" PropertyName="S electedValue" />

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
1023
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 ControlParameter to get the SelectedValue from the initial GridView to isolate the 1 row. My question is this: in the DetailsView, a column of data is returned that I would like to use to send as a parameter to a 3rd SqlDataSource, how do I do this?
2
1589
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 out of the query, it works. What seems to be happening is that if a field is NULL when it is read in through the select statement, it's causing the update statment not to find a match. I've got ConvertEmptyStringToNull not set (so it should...
3
4534
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 DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
2
14806
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 stored procedures and need to set the SqlDataSource to use the required stored procedure and pass the value in the TextBox to search with. The following code sets up the SelectParameters for the SqlDataSource:...
2
4210
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 'JoinDate' in ControlParameter 'JoinDate'." <asp:BoundField DataField="JoinDate" HeaderText="Joined" SortExpression="JoinDate" /> <asp:TemplateField HeaderText="Dates"> <ItemTemplate> <asp:DropDownList ID="RideDatesDropDownList" runat="server"
0
1620
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 below code with two different tables in the datasource for the gridview, one works the other times out. If I perform the same query in sql server manually both tables work fine and fast. if I hard code the where clause in the asp.net the code...
1
3545
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 to display the form once the user has entered the information and clicked Add.
2
5511
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 programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
0
1257
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 be the ID of a control of type IDataSource. A control with ID 'SqlDataSourceGroup' could not be found." I've been suggested to move the SqlDataSource out of the Accordion to get rid of the error message above, but when I do so the SqlDataSource
0
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9337
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8215
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.