Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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
 
Old May 10th, 2004, 02:44 AM
Authorized User
 
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrid and Drop Down Lists[Urgent]

Hello All
I am trying to popluate a datagrid with a dataset having drop down lists,my problem is that i want to populate datagrid's last column with drop downlists having different values relevant to the first ID column in datagrid.i.e,i want that if id column contains 1 the dropdown list relevent to that column contains values related to 1,if 2,drop down list should contain values relevant to 2 and so on.Another problem is that i have to have more that one rows in Datagrid with different values in drop down lists relevant to the first ID column.Kindly Help me its very urgent
Thanks

 
Old May 10th, 2004, 03:04 AM
Authorized User
 
Join Date: May 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't think you will be able to have a control within a control (dropdown within a datagrid). I think you will have to code the dropdowns seperatly once you have done the databind to the grid. There must be some way to loop through the number of rows in the grid an create a dropown with detiails corresponding to the first column of the grid.

 
Old May 10th, 2004, 03:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, it can be done, but it's not as easy as you'd expect. Take a look here:

http://msdn.microsoft.com/library/de...ntrol.asp#vbtc and look at the question: Displaying a Drop-Down List in Edit Mode.

This will explain some general ideas on how to add the drop-down. Since in your case you'll have different values for the drop-down, it's best to bind the datasource for the drop-down in the DataGrid1_ItemDataBound method. Inside that method, you have a reference to the current row being databound for the grid (through the parameter e), so you can retrieve its ID (possibly through the DataKeys collection), then select the appropriate related items from the database, get a reference to the drop-down control for the current row using FindControl (e.g.: (DropDownList) e.Item.FindControl("YourDropDown");) and finally bind its data and set the select item.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 10th, 2004, 03:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

ChrisLee,

Is this a guess, I'm quite sure you can have a dropdown inside a datagrid, and controls within controls generally.
I do not know enough to provide thorough explanation, but I suggest farhan wait a while before giving up.



======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old May 10th, 2004, 06:31 AM
Authorized User
 
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for co-operation
But i need the solution fast because i have to implement on my official project.Thats my job you know
Thanks a lot
Farhan

 
Old May 10th, 2004, 06:35 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you mean with "i need the solution fast"?? Isn't 25 minutes after your initial post fast enough?? ;)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 10th, 2004, 07:05 AM
Authorized User
 
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry Buddy(Imar)
Dont mind cos i have to do a lots of work instead of this work and in its tension i am unable to work on other modules,cos i have to complete it first
Regards
Farhan






Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting from multiple drop-lists Earl Hickey SQL Language 4 July 9th, 2008 03:34 PM
Help with dynamic drop down lists MarkGT Classic ASP Basics 3 April 29th, 2008 06:05 PM
Linked Drop Down Lists contagiouss_blue Excel VBA 6 June 8th, 2005 09:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.