 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 25th, 2007, 07:14 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sql Update Stament via DropDownlist in GridView
Table 1
___________
Id (pk)
TicketId(Fk)
.
.
Statusafter (int)
___________
The GridView gets its Values by the Foreign Key. This key delivers a set of records each with a unique id wich is the primary key.
Now i have a dropdownlist6 in the gridview that is attached to the statusafterid. I want that as i change the drowpdownlist the sqlupdatecommand is cast and the changed dataset connected to the pk is getting updated.
the problem is i cant specify a update statement because i dont know how to access the pk of that specific set. this is one possible way to update. can someone help me?
Ivan
__________________
Ivan
|
|

August 7th, 2007, 10:46 AM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ivan,
I am having essentially the same problem that you are having. I have a gridview that presents data from two tables, connected by FK's. I want to change data in a dropdown list containing data from 'table A', and take the ID of the data in the ddl and update the FK in 'table B'. I cannot figure out how to reference the ID. The ID is the PK in 'table A', and the FK in 'table B'. The ID is the uniquie identifier to the item in the ddl.
Please let me know if you have a solution.
Thanks!
Richard Lelle
Austin, Tx USA
|
|

August 7th, 2007, 12:18 PM
|
|
Friend of Wrox
|
|
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Guys, Can you tell me what statement you are writing for updating the tables?? Also, tell me where exactly you are facing the problem.
|
|

August 7th, 2007, 12:55 PM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
gaurav_jain2403,
As for now, my problem is not so much as a statement, but how to get the data. I have a gridview with a dropdown list that is a template field. This field is an 'EditItem' template, and when using the DrpDownList tasks/Choose Data Source for that field, I specify 'actv_dscr' as my 'data field for display', and the 'actv_id' as my 'data field for the value'. I am displaying the 'actv_dscr' in the ddl, and it's unique identifier (a FK to a primary table that I wish to update) is the 'actv_id'. If a user uses the ddl to change the 'actv_dscr', I need it's associated 'actv_id' to be updated on a (different) primary table. How to I reference the 'actv_id'? Is this enough info to go on? If not, I'll try to come up with whatever coding I have right now.
Thanks!
Richard Lelle
Austin, Tx USA
|
|

August 7th, 2007, 01:34 PM
|
|
Friend of Wrox
|
|
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
From where do you want to reference the actv_id? In database or .Net? If .Net, in which event you are trying to access its value and from where you are accessing value??
|
|

August 7th, 2007, 02:09 PM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I would want to access it in .NET, in a 'update' event/method. I'm thinking that when a user chooses a new description, then clicks the 'update' button, I would need the 'actv_id' associated to the 'actv_dscr' to update the primary table.
Richard Lelle
Austin, Tx USA
|
|

August 8th, 2007, 05:00 AM
|
|
Friend of Wrox
|
|
Join Date: Feb 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Use this code to access the value of actv_id:
string id = MyDropDownList.selectedValue;
|
|

August 8th, 2007, 09:08 AM
|
|
Authorized User
|
|
Join Date: May 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
To precise my Problem:
I have a DetailsView which represents One 'TicketId'
I have a gridview for that so called ticket which contains many other Table1.Id (pk) according to this one 'Ticketid'.
because i know that it is only possible to select one ticket from each gridview and than edit it, i want to know if it is possible to directly manipulate one value with a drop down list for example.
By the way i am asking myself if it is possible to load the gridview in edit mode?
Ivan
|
|
 |