473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drop Down List inside a Datagrid

Good Morning,
Quick question, I have an EditItemTemplat e inside a datagrid. It should
contain a drop down list of possible choices. I have an EditCommandColu mn.
The drop dow list column should initially contain the value of the field.
This works fine with
<ItemTemplate>< %# Container.DataI tem("NameType") %></ItemTemplate>

The desired effect is for the drop down list to databind to a query to show
possible choices when the user clicks the edit link. I can not get a
reference to the drop down list when the user clicks edit. Does anyone know
how to do this?

I tried page.findcontro l("controlname" ) and it does not work. Any ideas? I
get a NullReference Error when I do this, because I guess the control does
not exist on the page.

Thanks to everyone,
Chris
Nov 19 '05 #1
4 1467
Within the method that handles the datagrid EditCommand event you can get a
reference to the dropdown list by using the passed DataGridCommand EventArgs
as follows:
CType(e.Item.Fi ndControl("cont rolname"), DropDownList)
--
http://www.webswapp.com
http://www.societopia.net
"Chris Kettenbach" wrote:
Good Morning,
Quick question, I have an EditItemTemplat e inside a datagrid. It should
contain a drop down list of possible choices. I have an EditCommandColu mn.
The drop dow list column should initially contain the value of the field.
This works fine with
<ItemTemplate>< %# Container.DataI tem("NameType") %></ItemTemplate>

The desired effect is for the drop down list to databind to a query to show
possible choices when the user clicks the edit link. I can not get a
reference to the drop down list when the user clicks edit. Does anyone know
how to do this?

I tried page.findcontro l("controlname" ) and it does not work. Any ideas? I
get a NullReference Error when I do this, because I guess the control does
not exist on the page.

Thanks to everyone,
Chris

Nov 19 '05 #2
No, that still didn't work. Any other suggestions?
I ended up with this

Sub DataGrid_Edit(B yVal Sender As Object, ByVal E As
DataGridCommand EventArgs)

' turn on editing for the selected row

Dim ddl As DropDownList = CType(E.Item.Fi ndControl("drpN ameType"),
DropDownList)

If Not isEdit Then

dg1.EditItemInd ex = E.Item.ItemInde x

BindGrid()

End If
End Sub

Using a breakpoint, I see ddl = Nothing. What am I doing wrong here? Thanks!

"Phillip Williams" <Ph************ **@webswapp.com > wrote in message
news:B6******** *************** ***********@mic rosoft.com...
Within the method that handles the datagrid EditCommand event you can get
a
reference to the dropdown list by using the passed
DataGridCommand EventArgs
as follows:
CType(e.Item.Fi ndControl("cont rolname"), DropDownList)
--
http://www.webswapp.com
http://www.societopia.net
"Chris Kettenbach" wrote:
Good Morning,
Quick question, I have an EditItemTemplat e inside a datagrid. It should
contain a drop down list of possible choices. I have an
EditCommandColu mn.
The drop dow list column should initially contain the value of the field.
This works fine with
<ItemTemplate>< %# Container.DataI tem("NameType") %></ItemTemplate>

The desired effect is for the drop down list to databind to a query to
show
possible choices when the user clicks the edit link. I can not get a
reference to the drop down list when the user clicks edit. Does anyone
know
how to do this?

I tried page.findcontro l("controlname" ) and it does not work. Any ideas?
I
get a NullReference Error when I do this, because I guess the control
does
not exist on the page.

Thanks to everyone,
Chris

Nov 19 '05 #3
In the edit command handler try... DropDownList ddl = (DropDownList)
e.items.findcon trol("controlna me")

Charlie
"Chris Kettenbach" <in**@piasd.net > wrote in message
news:n7******** ************@gi ganews.com...
Good Morning,
Quick question, I have an EditItemTemplat e inside a datagrid. It should
contain a drop down list of possible choices. I have an
EditCommandColu mn. The drop dow list column should initially contain the
value of the field. This works fine with
<ItemTemplate>< %# Container.DataI tem("NameType") %></ItemTemplate>

The desired effect is for the drop down list to databind to a query to
show possible choices when the user clicks the edit link. I can not get a
reference to the drop down list when the user clicks edit. Does anyone
know how to do this?

I tried page.findcontro l("controlname" ) and it does not work. Any ideas?
I get a NullReference Error when I do this, because I guess the control
does not exist on the page.

Thanks to everyone,
Chris

Nov 19 '05 #4
Did that did the trick
Try going through this article at:-
http://www.4guysfromrolla.com/webtech/050801-1.shtml
Hope that helps
Patrick

"Charlie@NI SH" <cf*******@nish .org> wrote in message
news:On******** ******@TK2MSFTN GP12.phx.gbl...
In the edit command handler try... DropDownList ddl = (DropDownList)
e.items.findcon trol("controlna me")

Charlie
"Chris Kettenbach" <in**@piasd.net > wrote in message
news:n7******** ************@gi ganews.com...
Good Morning,
Quick question, I have an EditItemTemplat e inside a datagrid. It should
contain a drop down list of possible choices. I have an
EditCommandColu mn. The drop dow list column should initially contain the
value of the field. This works fine with
<ItemTemplate>< %# Container.DataI tem("NameType") %></ItemTemplate>

The desired effect is for the drop down list to databind to a query to
show possible choices when the user clicks the edit link. I can not get a reference to the drop down list when the user clicks edit. Does anyone
know how to do this?

I tried page.findcontro l("controlname" ) and it does not work. Any ideas? I get a NullReference Error when I do this, because I guess the control
does not exist on the page.

Thanks to everyone,
Chris


Nov 19 '05 #5

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

Similar topics

1
3447
by: Dec | last post by:
Ok to simplify things I'll just give an example. This is pretty much what I want to do (minus the postcode): http://www.perrys.co.uk/usedcar?ID=F5J9BNNBMVK00DF I have relatively little experience with databases (hate being a n00b) but I'm currently attempting to put myself through some sort of crash course.. How far have I got? Ok so using MS access 2003. I have a table (table1) with data with a
1
6540
by: Marlene harkcom | last post by:
I've got a datagrid with 5 bound columns in it as well as an edit/update/cancel column. I'm binding this to a dataset. One of the fields is always going to be one of three values. I want the user to be able to hit the edit button and have this particular column become a drop down list where the true value is selected, but they can choose one of the other two values. I've been able to add a dropdownlist column as a template column, but...
3
12453
by: Dharmen | last post by:
Hey Guys, I have a SQL database called price and a table called TB1, in it i have a column called "loc" I want to display the tiems in "loc" in a drop down list. I am able to do this in a datagrid. This is the code im using to display in datagrid: SqlConnection Conn=new SqlConnection("Data Source=localhost;Database=price; Integrated Security=SSPI;" +
2
2393
by: Eric Dan | last post by:
Hi, Even tough I was able to implement what I want in a weird and non efficient way, I would like to get an opinion what is the right way to achieve my task: Scenario: • Display a DataGrid that contains rows from a table from a databse (so far easy). • I would like to add a column to the DataGrid that will be a drop-down list so the user will be able to select a value from a pre-defined list of values
2
2102
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I am new in asp.net, i encounter some problems in using drop down list and datagrid. I have manage to bind the data into datagrid but i wanted to bind the data into the datagrid accroding to the selected brand from the drop down list. I do not have any idea how to do it. Does anyone knows how to bind the data in to datagrid accroding to the drop down list selected item? if there is a way would u mind paste the code or any...
0
1435
by: kaon | last post by:
Hi, Ive been looking for a way to capture an autopostback event of a dropdownlist in a datagrid control. the scenario is that, ive a datagrid, and there is a dropdownlist column in each of the row with each record (note the drop down dont only show when u edit a row, but it shows always for every row), when i change a value from the dropdown for any row of the grid, i want to get the row id (or the record id that i can by someway put in...
0
1509
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE. My question is simple, on my Projects form I have a 'search' button, which when clicked re-binds a datagrid with a RowFilter based on a number of user-input parameters. Two of these parameters are drop-down
0
2151
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in edititemtemplate with preselected value from the previous drop down list, so far I can only achieved with the regular drop down list in edititemtemplate with no preselected value from previous one. anyone can help me. thanks in advance. below is my current...
22
3442
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
8421
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
8325
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,...
0
8621
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
7354
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...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1734
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.