Wrox Programmer Forums
|
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 April 21st, 2005, 10:25 AM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drop Down List in Datagrid

If any body help me how can I put drop down list in my datagrid, I am trying since 6 days for this but it runs but I am not able to populate the list from the server..
In advance Thankyou.
aashish
__________________
Aashish Shah
 
Old April 21st, 2005, 12:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Use a template column, which can accept a dropdownlist.

Brian
 
Old April 22nd, 2005, 12:00 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Hope this helps. I use the combo in the template column like this
Code:
<asp:TemplateColumn HeaderText="State">
    <HeaderStyle HorizontalAlign="Center" CssClass="GridHead"></HeaderStyle>
    <ItemStyle HorizontalAlign="Left" CssClass="SearchResultItem"></ItemStyle>
    <ItemTemplate>
        <asp:Label id=lblEmp Runat="server" Text='<% # DataBinder.Eval(Container.DataItem, "EmpID") %>'>
        </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList id="cboEmp" Runat="server" ></asp:DropDownList>
    </EditItemTemplate>
</asp:TemplateColumn>
Regards
Ganesh
 
Old April 22nd, 2005, 09:44 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Here's an example of how to bind a DDL inside a datagrid to related information:

http://www.geekdork.com/samples/complexDatagrid.aspx

-Peter
 
Old April 26th, 2005, 11:11 PM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello there,

This is fine when it comes to populating a combobox in all the rows, but what if I would want to add a combobox in header only.
I would put a combo in header just to give a facility to filter records based on value selected in the combobox.

you can see such functionality in Microsoft Excel when you put auto filter, it shows comboboxes on each header column and puts unique values in it. so that if a user want to filter values he can do it just using these combo boxes.

Thank you



Vinod Pawar
India
 
Old April 26th, 2005, 11:27 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a little bit trickier because there is no template for the header of a column. Instead you need to latch into the ItemCreated or ItemDataBound event of the grid, then programmatically add the DDL control to the column header's controls collection.

Although I've not actually done this, I think the best approach might be to add the control in the ItemCreated handler (because this will get called on postbacks when the grid is re-constituted from viewstate) and then populate the DDL's data in the grid's ItemDataBound event. No need to rebind data in each ItemCreated call.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down list ashu_gupta75 Excel VBA 1 October 15th, 2007 05:52 PM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 6 March 18th, 2005 03:32 AM
Drop down list in datagrid help jmd ASP.NET 1.0 and 1.1 Basics 0 January 8th, 2005 04:24 PM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 8 September 16th, 2004 07:11 AM





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