473,657 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdownlist - using as a picklist

Hmm, nobody seems to want to answer any of my questions, but here goes again!

I have a Detailview control that is bound to a data source. Within the
Detailview control I have a number of dropdownlist controls that I want to
list available options but will be bound to the Detailview control. I can
achieve all this and seem to select the correct item from the datasource.
However, when I try to update, the bound dropdownlist value seems to be
missing and I get a db error saying cannot enter a null value. I have tried a
number of ways to achieve this by declaring on a page and now I am using code
behind to define & construct the dropdownlist items. Any help would be great
as I am beginning to suspect that old style ASP was a much better solution!..

Private Sub testbind(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender

ddl.ClearSelect ion()
ddl.DataSourceI D = "SqlDataSource2 "
ddl.DataValueFi eld = "Case_Contact_D irectorate_ID"

End Sub

Private Sub test2(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender
Dim con As New
SqlClient.SqlCo nnection(Config urationSettings .ConnectionStri ngs("AppConnect ionString1").Co nnectionString)
Dim comm As New SqlClient.SqlCo mmand("SELECT [Directorate_ID],
[Directorate_Nam e] FROM [Directorate]", con)
Dim rdr As SqlClient.SqlDa taReader
con.Open()
rdr = comm.ExecuteRea der

Dim di As ListItem
While rdr.Read
di = New ListItem(rdr(1) , rdr(0))
ddl.Items.Add(d i)
End While
con.Close()
con = Nothing
comm = Nothing
Dim val As Integer = ddl.Items(0).Va lue
'di = ddl.Items(0)
'ddl.Items.Remo ve(di)
'di = Nothing
For Each di In ddl.Items
If di.Value = val Then
di.Selected = True
Exit For
End If
Next

End Sub
Nov 19 '05 #1
2 3353
I don't see how the update is done... My first though would be to use the
profiler to see if this is the only field that has a problem or if something
is totally wrong about the update...

You may want also to try first with a single drop donw list to see if it
behaves as expected... (could it works for some but not all of your
dropdownlist).

Do you use ASP.NET 2.0 ?

Patrice
--

"Paul Owen" <Pa******@discu ssions.microsof t.com> a écrit dans le message de
news:3D******** *************** ***********@mic rosoft.com...
Hmm, nobody seems to want to answer any of my questions, but here goes again!
I have a Detailview control that is bound to a data source. Within the
Detailview control I have a number of dropdownlist controls that I want to
list available options but will be bound to the Detailview control. I can
achieve all this and seem to select the correct item from the datasource.
However, when I try to update, the bound dropdownlist value seems to be
missing and I get a db error saying cannot enter a null value. I have tried a number of ways to achieve this by declaring on a page and now I am using code behind to define & construct the dropdownlist items. Any help would be great as I am beginning to suspect that old style ASP was a much better solution!..
Private Sub testbind(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender

ddl.ClearSelect ion()
ddl.DataSourceI D = "SqlDataSource2 "
ddl.DataValueFi eld = "Case_Contact_D irectorate_ID"

End Sub

Private Sub test2(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender
Dim con As New
SqlClient.SqlCo nnection(Config urationSettings .ConnectionStri ngs("AppConnect i
onString1").Con nectionString) Dim comm As New SqlClient.SqlCo mmand("SELECT [Directorate_ID],
[Directorate_Nam e] FROM [Directorate]", con)
Dim rdr As SqlClient.SqlDa taReader
con.Open()
rdr = comm.ExecuteRea der

Dim di As ListItem
While rdr.Read
di = New ListItem(rdr(1) , rdr(0))
ddl.Items.Add(d i)
End While
con.Close()
con = Nothing
comm = Nothing
Dim val As Integer = ddl.Items(0).Va lue
'di = ddl.Items(0)
'ddl.Items.Remo ve(di)
'di = Nothing
For Each di In ddl.Items
If di.Value = val Then
di.Selected = True
Exit For
End If
Next

End Sub

Nov 19 '05 #2
Thanks for the reply Patrice,

I am using framework 2.0 and I am trying to carry out the update using the
datasource update and a stored procedure with 14 update params. I need to use
the dropdownlist controls to guarantee the integrity of the data...I am
prepared to code the update but I have so much trouble identifying and
accessing the cells that hold the data, I thought this would be more likely
to succeed!

"Patrice" wrote:
I don't see how the update is done... My first though would be to use the
profiler to see if this is the only field that has a problem or if something
is totally wrong about the update...

You may want also to try first with a single drop donw list to see if it
behaves as expected... (could it works for some but not all of your
dropdownlist).

Do you use ASP.NET 2.0 ?

Patrice
--

"Paul Owen" <Pa******@discu ssions.microsof t.com> a écrit dans le message de
news:3D******** *************** ***********@mic rosoft.com...
Hmm, nobody seems to want to answer any of my questions, but here goes

again!

I have a Detailview control that is bound to a data source. Within the
Detailview control I have a number of dropdownlist controls that I want to
list available options but will be bound to the Detailview control. I can
achieve all this and seem to select the correct item from the datasource.
However, when I try to update, the bound dropdownlist value seems to be
missing and I get a db error saying cannot enter a null value. I have

tried a
number of ways to achieve this by declaring on a page and now I am using

code
behind to define & construct the dropdownlist items. Any help would be

great
as I am beginning to suspect that old style ASP was a much better

solution!..

Private Sub testbind(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender

ddl.ClearSelect ion()
ddl.DataSourceI D = "SqlDataSource2 "
ddl.DataValueFi eld = "Case_Contact_D irectorate_ID"

End Sub

Private Sub test2(ByVal sender As Object, ByVal e As System.EventArg s)
Dim ddl As DropDownList
ddl = sender
Dim con As New

SqlClient.SqlCo nnection(Config urationSettings .ConnectionStri ngs("AppConnect i
onString1").Con nectionString)
Dim comm As New SqlClient.SqlCo mmand("SELECT [Directorate_ID],
[Directorate_Nam e] FROM [Directorate]", con)
Dim rdr As SqlClient.SqlDa taReader
con.Open()
rdr = comm.ExecuteRea der

Dim di As ListItem
While rdr.Read
di = New ListItem(rdr(1) , rdr(0))
ddl.Items.Add(d i)
End While
con.Close()
con = Nothing
comm = Nothing
Dim val As Integer = ddl.Items(0).Va lue
'di = ddl.Items(0)
'ddl.Items.Remo ve(di)
'di = Nothing
For Each di In ddl.Items
If di.Value = val Then
di.Selected = True
Exit For
End If
Next

End Sub


Nov 19 '05 #3

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

Similar topics

0
1664
by: DotNetJunkies User | last post by:
Hie, I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist i change the text displayed in the label in the same row. hier is my code: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web;
1
2626
by: Griff | last post by:
Hi! I'm using JavaScript on an HTML page for form validation. I have a form value (theForm.ProdType1) which represents a picklist from which users may make multiple selections; essentially, this is a Select object with the "multiple" attribute. There are 20 options to choose from in this object; one of the options (we'll call it option X) should NEVER be selected with any other option in the object. Let's say that the user has...
12
2321
by: Mike Brashars | last post by:
Hi all, I have been searching for a week and am unable to find and example to "Populate picklist from directory and return file name". I have a php script that reads a log file and plots a graph. Right now, the log name is hard coded. The logs are archived each day in the form of say ddmmyy.log and I would like to put a drop down list in the script that would allow my script to run off the "log" picked or default to the current "hard...
6
1977
by: (Pete Cresswell) | last post by:
I've got a situation where the user is expanding nodes in a TreeView and below a certain level, the child nodes become too numerous for them to deal with easily on a straight-up sequential list. What I'd like to do is populate a subform next to the tree view with the child items presented in a denser format. One essential feature of that presentation would be that individual items have to be clickable - i.e. the user doubleclicks on an...
4
5476
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
4
7447
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the placeholder,the user selects the required tags from the dropdownlists (if 5 Xml tags,then 5 dropdownlists each containing 5 xml tags) and now the btnSave button is selected which extracts the user selection form the dropdownlists.
10
5304
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a certain control by id, but I want to find all controls of a certain type (DropDownList in this case). Is there an easier way than to get a control count of the page, loop through all controls on that page, examine their type and, if they're a...
1
4651
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3492
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
8315
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
8734
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
8508
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
8608
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
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
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
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.