473,399 Members | 4,192 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,399 software developers and data experts.

Get value from dropdownlistbox into gridview and update database in SQL Server 2005

Hi,

I have a gridview control that displays data from 2 tabels in a sqlserver
2005 database. The table "Temperatures" has a field "LocationID" I populate
the gridview with a ObjectDataSource with the following connectionstring

Dim selTmpr As String = "SELECT Tmpr.TmprID, Tmpr.TmprName, Tmpr.TmprValue,
Tmpr.TmprRemark, Tmpr.TmprLocationID, Locations.Description " & _
"FROM Tmpr " & _
"LEFT OUTER JOIN Locations ON Tmpr.TmprLocationID = Locations.LocationID"

in the gridview I have ad a button "Edit" and when I press it the GV
changes into editmode displaying an update and cancel button. I have set the
property LocationID.visible to false and have added a collumn with a
DropDownListbox wich has a datasource "Locactions" (LocationID, Description)
in it. I have set the DataTextField to "Description" and the dataValueField
to "LocationID".

The ObjectDataSource has a Method "UpdateTemp"

How can I save the value of the DropDownList into my database ?

Many thanks in advance for any help on this,

Benny
Apr 19 '07 #1
3 3816
Seems there is no solution ...
"BenCoo" <te******@hotmail.comschreef in bericht
news:fn*********************@phobos.telenet-ops.be...
Hi,

I have a gridview control that displays data from 2 tabels in a sqlserver
2005 database. The table "Temperatures" has a field "LocationID" I
populate the gridview with a ObjectDataSource with the following
connectionstring

Dim selTmpr As String = "SELECT Tmpr.TmprID, Tmpr.TmprName,
Tmpr.TmprValue, Tmpr.TmprRemark, Tmpr.TmprLocationID,
Locations.Description " & _
"FROM Tmpr " & _
"LEFT OUTER JOIN Locations ON Tmpr.TmprLocationID = Locations.LocationID"

in the gridview I have ad a button "Edit" and when I press it the GV
changes into editmode displaying an update and cancel button. I have set
the property LocationID.visible to false and have added a collumn with a
DropDownListbox wich has a datasource "Locactions" (LocationID,
Description) in it. I have set the DataTextField to "Description" and the
dataValueField to "LocationID".

The ObjectDataSource has a Method "UpdateTemp"

How can I save the value of the DropDownList into my database ?

Many thanks in advance for any help on this,

Benny

Apr 27 '07 #2
type following in GridView1_itemUpdating Event.
e.NewValues("LocationID")=ctype(GridView1.FindCont rol("myDropDown"),DropDownList).SelectedValue

If you are inserting a New record, then type following in
GridView1_Iteminserting Event.

e.Values("LocationID")=ctype(GridView1.FindControl ("myDropDown"),DropDownList).SelectedValue

Please change "myDropDown" with your DropDown Control ID.

Best Regards,

Luqman

"BenCoo" <te******@hotmail.comwrote in message
news:i%*********************@phobos.telenet-ops.be...
Seems there is no solution ...
"BenCoo" <te******@hotmail.comschreef in bericht
news:fn*********************@phobos.telenet-ops.be...
>Hi,

I have a gridview control that displays data from 2 tabels in a
sqlserver 2005 database. The table "Temperatures" has a field
"LocationID" I populate the gridview with a ObjectDataSource with the
following connectionstring

Dim selTmpr As String = "SELECT Tmpr.TmprID, Tmpr.TmprName,
Tmpr.TmprValue, Tmpr.TmprRemark, Tmpr.TmprLocationID,
Locations.Description " & _
"FROM Tmpr " & _
"LEFT OUTER JOIN Locations ON Tmpr.TmprLocationID = Locations.LocationID"

in the gridview I have ad a button "Edit" and when I press it the GV
changes into editmode displaying an update and cancel button. I have set
the property LocationID.visible to false and have added a collumn with a
DropDownListbox wich has a datasource "Locactions" (LocationID,
Description) in it. I have set the DataTextField to "Description" and the
dataValueField to "LocationID".

The ObjectDataSource has a Method "UpdateTemp"

How can I save the value of the DropDownList into my database ?

Many thanks in advance for any help on this,

Benny


Apr 27 '07 #3
Hey Luqman,

Thanks for your solution, I go implement it right away :-)

Greetings,

Benny

"Luqman" <pe*******@cyber.net.pkschreef in bericht
news:eL**************@TK2MSFTNGP03.phx.gbl...
type following in GridView1_itemUpdating Event.
e.NewValues("LocationID")=ctype(GridView1.FindCont rol("myDropDown"),DropDownList).SelectedValue

If you are inserting a New record, then type following in
GridView1_Iteminserting Event.

e.Values("LocationID")=ctype(GridView1.FindControl ("myDropDown"),DropDownList).SelectedValue

Please change "myDropDown" with your DropDown Control ID.

Best Regards,

Luqman

"BenCoo" <te******@hotmail.comwrote in message
news:i%*********************@phobos.telenet-ops.be...
>Seems there is no solution ...
"BenCoo" <te******@hotmail.comschreef in bericht
news:fn*********************@phobos.telenet-ops.be...
>>Hi,

I have a gridview control that displays data from 2 tabels in a
sqlserver 2005 database. The table "Temperatures" has a field
"LocationID" I populate the gridview with a ObjectDataSource with the
following connectionstring

Dim selTmpr As String = "SELECT Tmpr.TmprID, Tmpr.TmprName,
Tmpr.TmprValue, Tmpr.TmprRemark, Tmpr.TmprLocationID,
Locations.Description " & _
"FROM Tmpr " & _
"LEFT OUTER JOIN Locations ON Tmpr.TmprLocationID =
Locations.LocationID"

in the gridview I have ad a button "Edit" and when I press it the GV
changes into editmode displaying an update and cancel button. I have set
the property LocationID.visible to false and have added a collumn with a
DropDownListbox wich has a datasource "Locactions" (LocationID,
Description) in it. I have set the DataTextField to "Description" and
the dataValueField to "LocationID".

The ObjectDataSource has a Method "UpdateTemp"

How can I save the value of the DropDownList into my database ?

Many thanks in advance for any help on this,

Benny



Apr 28 '07 #4

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

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
3
by: dm1608 | last post by:
Hello, I'm in the processing of learning .NET 2005 and an trying to rewrite a simple command line application that I wrote a couple years ago. I have the following requirements: 1) Read an XML...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
2
by: BenCoo | last post by:
Hello, In a gridview I've a checkbox (indicating a flag that is set or not). I fill the gridview via the wizard from ADO.NET 2.0 that generates automaticly the Insert, Update and Delete...
0
by: doomsday123 | last post by:
I have a gridview that displays a ORDER_ID in the first column and then I add 2 button columns on the end of it to approve or deny the order. If they approve it I want to update the database row's...
2
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.