GridView and DropDownList

B

Brian VanDyke

I have to display a table with customer data (GridView). However, I want to
be able to show DropDownList controls inside one of the columns, not just
textbox controls. Is this possible? Is it possible to have all of the
controls active so that a simple click of the Submit button updates all
customer records with the data in those DropDownLists?

I was able to do this with classic ASP, but with a GridView control (perhaps
I need a different structure?), I can only edit one record at a time, and I
can only seem to get textboxes in the table, not DropDownLists.

If possible, I need the DropDownList to fill with data from a data source as
well. Thanks for any help.

-Brian
 
T

Teemu Keiski

Hi,

by using TemplateFields, you can put anything you want on a GridView row.
For example:

DropDownList inside a GridView (or DataGrid)
http://webthingsconsidered.blogspot.com/2005/09/dropdownlist-inside-gridview-or.html

shows how to populate a DropDownList on the row.

Basically if you update all rows, you'd iterate through the GridView at
Button's Click and update it to the database to by row. I've explained the
idea at simple level:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/a...-hierarchy-of-ASP.NET-databound-controls.aspx
 
W

Walter Wang [MSFT]

Hi Brian,

As Teemu said, you could use a TemplateField to use whatever controls
inside it. You can find some examples here:

#Using TemplateFields in the GridView Control
http://www.asp.net/learn/dataaccess/tutorial12vb.aspx?tabid=63


(There's also many useful ASP.NET 2.0 Data Tutorials here:
http://www.asp.net/learn/dataaccess/default.aspx?tabid=63)

Is it possible to have all of the controls active so that a simple click
of the Submit button updates all customer records with the data in those
DropDownLists?


I'm not sure if I fully understand your above question. Do you mean put all
rows of a GridView in edit mode and update them in a batch? If this is the
case, then you may find following example useful:

#Matt Dotson's .NET Tips & Tricks : Real World GridView: Bulk Editing
http://blogs.msdn.com/mattdotson/articles/490868.aspx


Hope this helps.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Brian,

Have you seen above replies? Would you please reply here to let us know the
status of this post? Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
May 14, 2007
Messages
1
Reaction score
0
Walter,

I am trying to do a bulk update, insert, delete using the gridview. The problem with Matt Dotson's Bulk Edit grid is that it all items are in edit mode. The specifications that we are coding to require that the user can insert rows, edit rows, and delete rows and then do a bulk update of it all. Is this possible with the grid view?

Thanks,
Greg Finzer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top