473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1791
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******************@TK2MSFTNGP11.phx.gbl...
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"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Person
Name" />
<asp:TemplateField HeaderText="Best Friend">
<ItemTemplate>
<asp:DropDownList ID="ddlFriend"
runat="server"
AppendDataBoundItems="true"
DataTextField="Name"
OnSelectedIndexChanged="Runit"
DataValueField="Name">
<asp:ListItem Text="-"
Value="0"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

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

((DropDownList)gvPeople.Controls[0].Controls[n].Controls[1].FindControl("ddlFriend")).SelectedIndexChanged
+= new EventHandler(Default4_SelectedIndexChanged);

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
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...
3
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,...
1
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...
6
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...
2
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...
0
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...
0
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 +...
6
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...
4
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.