473,811 Members | 3,314 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDown in DataGrid

RS
Hello,
I need to add a dropdown list to datagrid. Once page is displayed on change
of the selection of the dropdown for that row, I need to be able to capture
the value of the dropdown and do some things in the code behind. I got
Dropdown list to show up in the grid and all values that I need are there.
What I am missing is capture of onchange event.

Does anyone have any idea how to capture event on the page behind?

Thanks so much to everyone!!
Dec 5 '05 #1
2 1818
There's a great series on doing stuff like this as 4guysfromrolla. com. It's
a long series, but is a good guide. He turned it into a book called
"ASP.NET Data Web Controls Kick Start", which is for ASP.NET 1.1, so unless
you're going to be with 1.1 for a long while, I'd stick with the on-line
articles (I did buy the book about a year ago, and it is well worth it, but
the new 2.0 framework is now out, and the book isn't so relevant to that).

"RS" <WW*@WWW.WWW> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Hello,
I need to add a dropdown list to datagrid. Once page is displayed on change of the selection of the dropdown for that row, I need to be able to capture the value of the dropdown and do some things in the code behind. I got
Dropdown list to show up in the grid and all values that I need are there.
What I am missing is capture of onchange event.

Does anyone have any idea how to capture event on the page behind?

Thanks so much to everyone!!

Dec 5 '05 #2
Here's one way to do it... This is a 2.0 Gridview...

<asp:GridView ID="gvPeople" runat="server"
AutoGenerateCol umns="false">
<Columns>
<asp:BoundFie ld DataField="Name " HeaderText="Per son
Name" />
<asp:TemplateFi eld HeaderText="Bes t Friend">
<ItemTemplate >
<asp:DropDownLi st ID="ddlFriend"
runat="server"
AppendDataBound Items="true"
DataTextField=" Name"
OnSelectedIndex Changed="Runit"
DataValueField= "Name">
<asp:ListItem Text="-"
Value="0"></asp:ListItem>
</asp:DropDownLis t>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>

Or you can always do something that looks like this...

((DropDownList) gvPeople.Contro ls[0].Controls[n].Controls[1].FindControl("d dlFriend")).Sel ectedIndexChang ed
+= new EventHandler(De fault4_Selected IndexChanged);

I think declaratively is easier myself... believe me it's even EASIER
in .NET 2.0 with the data source controls.

Dec 5 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2036
by: Kilic Beg via .NET 247 | last post by:
Hi, I am having trouble adding a dropdown to DataGrid at runtime. I create all boundColumns and the TemplateColumn for the dropdown at runtime. The dropdown has a different datasource then the DataGrid. 1. If I try to bind the second datasource to the dropdown I get An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll. 2. If I comment that line out it displays always the dropdown. I want it to...
3
7316
by: Big Dave | last post by:
I know it's been asked a million times before, but I still can't seem to find an answer that works. I've got a dropdown list in the footer template of a datagrid. The dropdown list databinds, but I can't seem to add a blank item to the top of the dropdown list. I've tried using the code to add this by placing it in both the page_load and the datagrid.itemDataBound event, but neither seems to work. I've also referenced the control by
1
1967
by: Vijay Kerji | last post by:
Hi, I have a datagrid with dropdown list and Remove hyperlink in it as columns. When I remove a row from the datagrid, Dropdown list selection is retaining its previous value. i.e, removed Dropdown item selection is applied to the next dropdown list. Is there any way to fix this problem?
6
5398
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I am receiving errors when trying to set the selected value of the dropdown within the ItemDataBound() subroutine. Below is the code I am using. I hope someone can tell me if this is possible. '''HTML''' <asp:datagrid id="dgAssignments"...
2
2861
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
0
2918
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
0
1426
by: anjupt | last post by:
Hi, I can add values to a dropdown from 1 to 100 using a while loop in page load.ie Dim i = 1 While i <= 100 Me.DropDownList2.Items.Add(i) ' i = i + 1 End While this code if written in page load gives out a dropdown consisting of numbers 1 to 100 on execution of the page ..
6
5860
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
4
1448
by: youvrajasnsm | last post by:
Hi All, >I am using datagrid control in asp.net with C#. >I have two dropdown list in datagrid e.g. one dropdown have Classname and another have Studentname. >now I want to show all the studentname in second dropdown related to their class selected in first dropdown. >plz help me in above. >Remember i am using both dropdown in a datagrid.......... Thanks.
5
5483
by: Me LK | last post by:
I need to add a line to choose a size into a dropdown . Since I have the dropdown nested inside a datagrid this is not working.When a page displays there are several rows of dropdowns but only the top dropdown has the option added. The others do not. I am using the following code Dim ddlPsize As DropDownList ddlPsize = (itemInfo.Items(0).FindControl("ddlsizes")) ddlPsize.Items.Insert(0, "Choose a Size")
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.