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 February 12th, 2004, 12:36 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default inserting Dropdownlist in Data Grid.

I need help to inserting a drop down list which I have populated with the data from the server . I want to set that dropdown list for each and every row of the table of the data grid.
In advance thanks

Aashish Shah
__________________
Aashish Shah
 
Old February 12th, 2004, 01:38 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Where do you want to insert it? Into an existing column or a new column?

 
Old February 12th, 2004, 01:43 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the following code


<Columns>
<asp:BoundColumn Visible="False" DataField="attend_date" HeaderText="Date"></asp:BoundColumn>
<asp:BoundColumn DataField="permnum" HeaderText="Student ID"></asp:BoundColumn>
<asp:BoundColumn DataField="student_name" HeaderText="Student Name"></asp:BoundColumn>
<asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
<asp:BoundColumn DataField="" HeaderText="Reason"></asp:BoundColumn>
!!!!!!!!!!I want to insert dropdownlist here!!!!!!!!!!
like this:-
<asp:DropDownList id="txtReason" runat="server" width="150"></asp:DropDownList>
</Columns>
 
Old February 12th, 2004, 02:38 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

aashish,

You need to add a template column to your datagrid.
You can do it in the property builder (if you're using vs 2003 or whatever) or in the html.

Here's what it would look like:
Code:
<asp:TemplateColumn HeaderText="Address 2">
<ItemTemplate>
<asp:dropdownlist runat=server id=state>
<asp:listitem>AK</listitem>
<asp:listitem>TX</listitem>
</dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>
If you want to populate the dropdown dynamically, you will need to specifiy the datasource of the dropdownlist.
Code:
<asp:dropdownlist 
runat=server 
id=state 
DataTextField="stateName" 
DataValueField="stateAppr" 
DataSource='<%#buildStateList()%>'>
</dropdownlist>
Good luck

 
Old February 12th, 2004, 03:18 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'asp:dropdownlist' is of type 'System.Web.UI.WebControls.DropDownList'.

Source Error:


Line 221: <asp:BoundColumn DataField="scn" HeaderText="Current School"></asp:BoundColumn>
Line 222: <asp:BoundColumn DataField="" HeaderText="Reason"></asp:BoundColumn>
Line 223: <asp:dropdownlist runat=server id="txtReason" DataTextField="Reason" DataValueField="code" DataSource='<%#GetDataSource(strSQL2)%>'></dropdownlist>
Line 224:
Line 225: </Columns>


Source File: I:\SIS Web Sites\Alternate Edu\data_taft1.aspx Line: 223


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.288; ASP.NET Version:1.0.3705.288

Aashish Shah
 
Old February 12th, 2004, 03:19 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is giving me this error!!!!!!!1
Please help me out

thanks

Aashish Shah
 
Old February 12th, 2004, 03:25 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to put it into a template column. You can't just drop it into the datagrid. Look at the first code block of my previous post.
mark

 
Old February 12th, 2004, 04:12 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thnaks a lot!!!!!!!!!!!!!!!!!1

Aashish Shah
 
Old February 12th, 2004, 04:12 PM
Authorized User
 
Join Date: Feb 2004
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Mark ..... thanks!!!!!!!!!!!!!!!!!!!!!

Aashish Shah
 
Old February 12th, 2004, 04:19 PM
Authorized User
 
Join Date: Jan 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're welcome
mark






Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting data using a dropdownlist johan_st ASP.NET 2.0 Basics 0 January 20th, 2007 07:45 AM
Setting Selected attribute of DropDownList in Grid jlrolin ASP.NET 1.0 and 1.1 Professional 0 June 13th, 2006 01:59 PM
Export data from data grid to excel pomoc VB.NET 2002/2003 Basics 0 December 16th, 2005 03:11 PM
Export data from data grid to Excel pomoc Visual Basic 2005 Basics 0 December 16th, 2005 02:56 PM
trying to load db data into data grid itsajourney Beginning VB 6 2 June 7th, 2005 12:05 PM





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